Tag and Release #1
This file contains hidden or 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: Tag and Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to tag' | |
| required: true | |
| default: 'v0.5.0' | |
| type: string | |
| is_draft: | |
| description: 'Is draft release?' | |
| default: false | |
| type: boolean | |
| is_prerelease: | |
| description: 'Is prerelease?' | |
| default: false | |
| type: boolean | |
| name: | |
| description: 'Name' | |
| required: false | |
| default: '' | |
| type: string | |
| release_description: | |
| description: 'Release description (Markdown supported)' | |
| required: false | |
| default: '' | |
| type: string | |
| jobs: | |
| tag: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "[email protected]" | |
| - name: Tag the branch | |
| working-directory: ${{ github.workspace }} | |
| run: | | |
| git tag ${{ github.event.inputs.version }} | |
| git push origin ${{ github.event.inputs.version }} | |
| build: | |
| needs: tag | |
| uses: ./.github/workflows/build.yml | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-tags: true | |
| - name: Get commit hash | |
| id: vars | |
| run: | | |
| git tag | |
| echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
| - name: Determine Release Name | |
| id: determine_name | |
| run: | | |
| if [ -z "${{ github.event.inputs.name }}" ]; then | |
| echo "name=PicoBoot ${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "name=${{ github.event.inputs.name }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Retrieve artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: picoboot-${{ steps.vars.outputs.sha_short }} | |
| path: dist/ | |
| - name: Build Changelog | |
| id: build_changelog | |
| uses: mikepenz/release-changelog-builder-action@v5 | |
| with: | |
| mode: "COMMIT" | |
| toTag: ${{ github.event.inputs.version }} | |
| configurationJson: | | |
| { | |
| "template": "#{{UNCATEGORIZED}}", | |
| "commit_template": "* #{{TITLE}} by @#{{AUTHOR}} (#{{MERGE_SHA}})", | |
| "empty_template": "_No notable changes in this version._", | |
| "categories": [] | |
| } | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Prepare release description | |
| env: | |
| DESCRIPTION: ${{ github.event.inputs.release_description }} | |
| RELEASE_NAME: ${{ steps.determine_name.outputs.name }} | |
| CHANGELOG: ${{ steps.build_changelog.outputs.changelog }} | |
| run: | | |
| content=$(cat .github/release_description.md) | |
| content=${content//@DESCRIPTION@/$DESCRIPTION} | |
| content=${content//@CHANGELOG@/$CHANGELOG} | |
| echo "$content" > release-description.md | |
| - name: Calculate artifact checksum | |
| run: | | |
| echo '```' >> release-description.md | |
| cd dist/ | |
| sha256sum picoboot_full_pico.uf2 >> ../release-description.md | |
| sha256sum picoboot_full_pico2.uf2 >> ../release-description.md | |
| cd ../ | |
| echo '```' >> release-description.md | |
| - name: Set up Git | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "[email protected]" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ steps.determine_name.outputs.name }} | |
| tag_name: ${{ github.event.inputs.version }} | |
| draft: ${{ github.event.inputs.is_draft }} | |
| prerelease: ${{ github.event.inputs.is_prerelease }} | |
| body_path: ${{ github.workspace }}/release-description.md | |
| files: | | |
| dist/picoboot_full_pico.uf2 | |
| dist/picoboot_full_pico2.uf2 |