release #13
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 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| increase_major: | |
| description: Increase major version? | |
| type: choice | |
| options: | |
| - "Yes" | |
| - "No" | |
| default: "Yes" | |
| dry_run: | |
| description: Perform a dry run | |
| required: false | |
| type: boolean | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout resource repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: szapp/Toolkit | |
| submodules: recursive | |
| token: ${{ secrets.TOOLKIT_SUBMODULES }} | |
| persist-credentials: false | |
| path: _resources | |
| - name: Set minor and resource versions | |
| run: | | |
| lego=$(cat _resources/Ninja/Toolkit/LeGo/LeGo.d | grep -oP "^const string LeGo_Version = \"LeGo \d+\.\d+\.\d+-N\K\d{3}") | |
| ikarus=$(cat _resources/Ninja/Toolkit/Ikarus/Ikarus.d | grep -oP "^const int IKARUS_VERSION = \K\d{5,}") | |
| echo "VIKARUS_NEW=${ikarus}" >> $GITHUB_ENV | |
| echo "VLEGO_NEW=${lego}" >> $GITHUB_ENV | |
| echo "VMINOR=${lego#*0}" >> $GITHUB_ENV | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT }} | |
| fetch-tags: true | |
| fetch-depth: 0 | |
| - name: Set major version | |
| run: | | |
| source metadata | |
| if [ "${{ inputs.increase_major }}" == "Yes" ]; then | |
| VMAJOR=$[$VMAJOR+1] | |
| echo "Increase major version to $VMAJOR" | |
| if [ $VMAJOR -gt 9 ]; then | |
| echo "::error title=Invalid version::The major version needs to be one digit!" | |
| exit 1 | |
| fi | |
| fi | |
| echo "VMAJOR=$VMAJOR" >> $GITHUB_ENV | |
| - name: Bump version number and release years | |
| run: | | |
| sed -i -r "s/(^export RYEARS=[0-9]{4}-)[0-9]{4}$/\1$(date +'%Y')/" metadata | |
| sed -i -r "s/(^export VMAJOR=)-?[0-9]+$/\1${{ env.VMAJOR }}/" metadata | |
| sed -i -r "s/(^export VMINOR=)[0-9]+$/\1${{ env.VMINOR }}/" metadata | |
| sed -i -r "s/(^export IKARUS_VERSION=)[0-9]+$/\1${{ env.VIKARUS_NEW }}/" metadata | |
| sed -i -r "s/(^export LEGO_N_VERSION=)[0-9]+$/\1${{ env.VLEGO_NEW }}/" metadata | |
| source metadata | |
| ver=$VBASE.$VMAJOR.$VMINOR | |
| tag=v$ver | |
| echo "VERSION=$ver" >> $GITHUB_ENV | |
| echo "TAG=$tag" >> $GITHUB_ENV | |
| tagexists=$(git tag | grep -oP "^${tag}$" | wc -l) | |
| if [ $tagexists -gt 0 ]; then | |
| echo "::error title=Invalid version::A tag with the version $tag already exists!" | |
| exit 1 | |
| fi | |
| changes="$(git diff -- metadata | tail -n +6 | head -n5 | sed 's/export //g')" | |
| echo "### Version changes | |
| \`\`\`diff | |
| $changes | |
| \`\`\` | |
| " >> $GITHUB_STEP_SUMMARY | |
| - name: Commit changes | |
| if: ${{ !inputs.dry_run }} | |
| run: | | |
| git config user.name $(git log -1 --format=%an) | |
| git config user.email $(git log -1 --format=%ae) | |
| git add metadata | |
| git commit -m "Bump version number" | |
| git tag -a ${{ env.TAG }} -m "Version ${{ env.VERSION }}" | |
| git push --follow-tags | |
| - name: Draft release | |
| if: ${{ !inputs.dry_run }} | |
| run: | | |
| tag=${{ env.TAG }} | |
| changelogdate=$(date +"%b-%-d-%Y") | |
| changelogid="${tag//./}-${changelogdate,,}" | |
| notes="<!-- <div align=\"center\"><table width=\"100%\"><td><b>⚠ This version is outdated. Please use the <a href=\"https://github.com/szapp/Ninja/releases/latest\">lastest version</a> instead. ⚠ </b></td></table></div> --> | |
| <!-- Short description --> | |
| 🗒️ [Change log](https://github.com/szapp/Ninja/wiki/Changelog#$changelogid) | |
| 🖥️ [Installation instructions](https://github.com/szapp/Ninja/wiki/Installation-(EN)#wiki-wrapper) | |
| #️⃣ [Check sums](https://github.com/szapp/Ninja/wiki/Checksums#wiki-wrapper) for verification. | |
| <img src=\"https://github.com/szapp/GothicFreeAim/assets/20203034/49fbc81a-69b2-4ee2-bfcb-eae746546894\" alt=\"\" height=\"12pt\" /> <a href=\"https://ko-fi.com/szapp\">Support the project</a> to ensure its journey continues! | |
| " | |
| gh release create $tag -R ${{ github.repository }} -d --verify-tag --title "Ninja ${{ env.VERSION }}" --notes "$notes" || echo "::error title=Release failed::Could not draft release for tag $tag" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.PAT }} |