Release #9
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: Release | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| type: string | |
| required: false | |
| description: "Version number e.g., 4.2.0" | |
| schedule: | |
| - cron: 0 0 * * * | |
| env: | |
| VERSION: ${{inputs.version || 'nightly'}} | |
| VERSION_WITH_V: ${{inputs.version != '' && format('v{0}', inputs.version) || 'nightly'}} | |
| jobs: | |
| release-info: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Release info | |
| run: | | |
| echo "VERSION: $VERSION" | |
| echo "VERSION_WITH_V: $VERSION_WITH_V" | |
| build: | |
| needs: [release-info] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Build | |
| run: | | |
| echo "Artifact 1" > artifact1.txt | |
| echo "Artifact 2" > artifact2.txt | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: artifacts | |
| path: | | |
| artifact1.txt | |
| artifact2.txt | |
| create-release: | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Download Linux build artifacts | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: artifacts | |
| path: ./build | |
| - name: Create release ZIP | |
| working-directory: ./build | |
| run: | | |
| zip myproject-${VERSION_WITH_V}.zip \ | |
| artifact1.txt \ | |
| artifact2.txt | |
| - name: Create release notes | |
| run: | | |
| chmod +x ./scripts/rz.py | |
| if [[ "$VERSION" != "nightly" ]]; then | |
| ./scripts/rz.py create $VERSION | |
| else | |
| ./scripts/rz.py create nightly \ | |
| --no-changes \ | |
| --top=":warning: **Nightly build**: This nightly-release may contain experimental features and breaking changes." | |
| fi | |
| - name: Delete release tag | |
| run: | | |
| if gh release view $VERSION_WITH_V &> /dev/null; then | |
| gh release delete $VERSION_WITH_V --cleanup-tag --yes | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create a new branch for the release | |
| run: | | |
| if git ls-remote --exit-code --heads origin $VERSION_WITH_V; then | |
| git push origin -d $VERSION_WITH_V | |
| fi | |
| git checkout -b $VERSION_WITH_V | |
| git push origin $VERSION_WITH_V | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create the new release | |
| run: | | |
| if [[ "$VERSION" != "nightly" ]]; then | |
| gh release create $VERSION_WITH_V \ | |
| ./build/myproject-${VERSION_WITH_V}.zip \ | |
| --title "MyProject $VERSION_WITH_V released!" \ | |
| --notes-file .tmprz/release_notes.md | |
| else | |
| gh release create nightly \ | |
| ./build/myproject-nightly.zip \ | |
| --title "MyProject nightly release" \ | |
| --notes-file .tmprz/release_notes.md \ | |
| --prerelease | |
| fi | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Send a pull request for the modified changelog | |
| if: ${{ env.VERSION != 'nightly' }} | |
| run: | | |
| branch=changelog-update-$VERSION_WITH_V | |
| git checkout -b $branch | |
| git add CHANGELOG.md | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git commit -m "Update changelog for $VERSION_WITH_V" | |
| git push origin $branch | |
| gh pr create \ | |
| --title "Update changelog after $VERSION_WITH_V release" \ | |
| --body "This pull request updates CHANGELOG.md file after the recent release." \ | |
| --assignee "${{github.actor}}" | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Clean release notes | |
| run: | | |
| ./scripts/rz.py cleanup | |
| announcement: | |
| needs: [create-release] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send a Discord message | |
| if: ${{ env.VERSION != 'nightly' }} | |
| env: | |
| DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} | |
| uses: Ilshidur/action-discord@master | |
| with: | |
| args: | | |
| MyProject ${{ env.VERSION_WITH_V }} released 🚀 | |
| Changelog: https://github.com/codezri/gha-template/releases/tag/${{ env.VERSION_WITH_V }} |