Return to Development #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Draft Release | |
on: | |
pull_request: | |
types: [closed] | |
workflow_dispatch: | |
inputs: | |
version: | |
type: string | |
description: The version with a 'v'. For example, v1.0.0. | |
jobs: | |
draft_release: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release')) }} | |
steps: | |
- name: Validate input version starts with 'v' | |
if: ${{ github.event_name == 'workflow_dispatch' && !startsWith(github.event.inputs.version, 'v') }} | |
run: | | |
echo "version '${{ github.event.inputs.version }}' is invalid, it must start with 'v'" | |
exit 1 | |
- name: Set VERSION variable from tag | |
run: | | |
VERSION=${{ github.event.inputs.version || github.head_ref}} | |
echo "VERSION=${VERSION##*/}" >> $GITHUB_ENV | |
- name: print version | |
run: echo "env version is set to ${{ env.VERSION }}" | |
- name: Checkout repository code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# skip generating assets, which potentially requires setup-go | |
- name: Fetch Changelog | |
run: sed -n '/## \[/{:loop n; /^$/n; /## \[/q; p; b loop}' CHANGELOG.md > ${{env.VERSION}}-CHANGELOG.md | |
- name: show notes | |
run: sed -n '/## \[/{:loop n; /^$/n; /## \[/q; p; b loop}' CHANGELOG.md | |
# todo: add release files back to the assets | |
# the second ${{env.VERSION}} is the tag see https://cli.github.com/manual/gh_release_create | |
# todo: replace ./random.txt with actual files | |
- run: gh release create --draft --notes-file ${{env.VERSION}}-CHANGELOG.md --title ${{env.VERSION}} ${{env.VERSION}} ./random.txt | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# todo: add slack notification back |