Publish release #2
Workflow file for this run
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: Publish release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: The version to release (e.g., "v1.2.3") | |
| required: true | |
| dry-run: | |
| description: Perform a dry run without creating a release | |
| required: false | |
| default: false | |
| type: boolean | |
| jobs: | |
| build: | |
| permissions: | |
| contents: read | |
| uses: ./.github/workflows/ci.yml | |
| release: | |
| name: Create GitHub release | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Verify tag format | |
| run: | | |
| if [[ ! "${{ github.event.inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?$ ]]; then | |
| echo "Error: Version tag '${{ github.event.inputs.version }}' is not in the correct format (e.g., v1.2.3 or v1.2.3-beta.1)" | |
| exit 1 | |
| fi | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: './artifacts' | |
| - name: Display structure of downloaded files | |
| run: ls -R | |
| working-directory: './artifacts' | |
| - name: Install dependencies | |
| run: npm i | |
| - name: Generate release notes | |
| run: | | |
| npx tsx script/generate-release-notes.ts "${{ github.workspace }}/artifacts" "${{ inputs.ref }}" "${{ secrets.GITHUB_TOKEN }}" | |
| RELEASE_NOTES_FILE=script/release_notes.txt | |
| if [[ ! -f "$RELEASE_NOTES_FILE" ]]; then | |
| echo "$RELEASE_NOTES_FILE does not exist. Something might have gone wrong while generating the release notes." | |
| exit 1 | |
| fi | |
| - name: Get author name | |
| id: get_author | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| echo name=`gh api users/${{ github.actor }} | jq -j .name` >> $GITHUB_OUTPUT | |
| - name: Create tag | |
| env: | |
| GIT_AUTHOR_NAME: ${{steps.get_author.outputs.name || github.actor}} | |
| GIT_AUTHOR_EMAIL: ${{github.actor_id}}+${{github.actor}}@users.noreply.github.com | |
| GIT_COMMITTER_NAME: github-actions[bot] | |
| GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com | |
| run: | | |
| git tag ${{ github.event.inputs.version }} | |
| git push origin ${{ github.event.inputs['dry-run'] == 'true' && '--dry-run ' || '' }}${{ github.event.inputs.version }} | |
| - name: Release | |
| uses: softprops/action-gh-release@v2 | |
| if: ${{ github.event.inputs['dry-run'] != 'true' }} | |
| with: | |
| body_path: ${{ github.workspace }}/script/release_notes.txt | |
| tag_name: ${{ github.event.inputs.version }} | |
| draft: true | |
| prerelease: false | |
| files: ${{ github.workspace }}/artifacts/**/* | |
| fail_on_unmatched_files: true |