ci: support semantic versioning with pre-release suffix #20
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: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'src/version.h' | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| attestations: write | |
| artifact-metadata: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Get Last Tag | |
| run: | | |
| LAST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1) || echo "0.0.0") | |
| echo "LAST_TAG=$LAST_TAG" >> $GITHUB_ENV | |
| - name: Get Version from version.h | |
| run: | | |
| MAJOR=$(grep '#define RELEASE_VER_MAIN' src/version.h | awk '{print $3}') | |
| MINOR=$(grep '#define RELEASE_VER_SUB' src/version.h | awk '{print $3}') | |
| PATCH=$(grep '#define RELEASE_VER_FIX' src/version.h | awk '{print $3}') | |
| PRE_SUFFIX=$(grep '#define RELEASE_VER_PRE_SUFFIX' src/version.h | awk '{print $3}' | tr -d '"') | |
| VERSION="$MAJOR.$MINOR.$PATCH$PRE_SUFFIX" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Create Tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git tag -a "${{ env.VERSION }}" -m "${{ env.VERSION }}" | |
| - name: Generate Release Notes | |
| run: | | |
| chmod +x .github/workflows/genReleaseNote.sh | |
| .github/workflows/genReleaseNote.sh -v ${{ env.LAST_TAG }}...${{ env.VERSION }} | |
| - name: Get Latest Workflow Run | |
| id: workflow | |
| run: | | |
| RUN_ID=$(gh api repos/${{ github.repository }}/actions/workflows/build.yml/runs \ | |
| --jq '.workflow_runs[] | select(.event == "push" and .head_branch == "main" and .conclusion == "success") | .id' | head -n 1) | |
| if [ -z "$RUN_ID" ]; then | |
| echo "No successful push build run found for main branch." >&2 | |
| exit 1 | |
| fi | |
| echo "run_id=$RUN_ID" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get SetDll Latest Release | |
| id: setdll | |
| run: | | |
| RELEASE_INFO=$(gh api repos/Bush2021/setdll/releases/latest) | |
| DOWNLOAD_URL=$(echo "$RELEASE_INFO" | jq -r '.assets[0].browser_download_url') | |
| echo "download_url=$DOWNLOAD_URL" >> $GITHUB_OUTPUT | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download Build Artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| path: build_artifacts | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| run-id: ${{ steps.workflow.outputs.run_id }} | |
| - name: Package All Artifacts | |
| run: | | |
| mkdir -p artifacts/x86/{App,Data,Cache} | |
| mkdir -p artifacts/x64/{App,Data,Cache} | |
| mkdir -p artifacts/arm64/{App,Data,Cache} | |
| cp -r build_artifacts/version-x86-${{ env.VERSION }}/* artifacts/x86/App/ | |
| cp -r build_artifacts/version-x64-${{ env.VERSION }}/* artifacts/x64/App/ | |
| cp -r build_artifacts/version-arm64-${{ env.VERSION }}/* artifacts/arm64/App/ | |
| cp src/chrome++.ini artifacts/x86/App/ | |
| cp src/chrome++.ini artifacts/x64/App/ | |
| cp src/chrome++.ini artifacts/arm64/App/ | |
| cd artifacts | |
| 7z a -mx=9 -m0=lzma2 -mmt=on ../Chrome++_v${{ env.VERSION }}_x86_x64_arm64.7z * | |
| cd .. | |
| - name: Package SetDll | |
| run: | | |
| mkdir -p setdll_package_contents | |
| wget -O setdll_latest.7z ${{ steps.setdll.outputs.download_url }} | |
| 7z x setdll_latest.7z -o./setdll_package_contents | |
| rm setdll_latest.7z | |
| cp ./build_artifacts/version-x86-${{ env.VERSION }}/version.dll ./setdll_package_contents/version-x86.dll | |
| cp ./build_artifacts/version-x64-${{ env.VERSION }}/version.dll ./setdll_package_contents/version-x64.dll | |
| cp ./build_artifacts/version-arm64-${{ env.VERSION }}/version.dll ./setdll_package_contents/version-arm64.dll | |
| cp ./src/chrome++.ini ./setdll_package_contents/chrome++.ini | |
| cd setdll_package_contents | |
| echo "Contents of 'setdll_package_contents' directory before zipping:" | |
| ls -Al | |
| 7z a -mx=9 -ms=on -m0=lzma2 -mmt=on ../setdll.7z * | |
| cd .. | |
| - name: Attest Release Packages | |
| uses: actions/attest-build-provenance@v3 | |
| with: | |
| subject-path: | | |
| Chrome++_v${{ env.VERSION }}_x86_x64_arm64.7z | |
| setdll.7z | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2.5.0 | |
| with: | |
| files: | | |
| Chrome++_v${{ env.VERSION }}_x86_x64_arm64.7z | |
| setdll.7z | |
| body_path: release.md | |
| tag_name: ${{ env.VERSION }} | |
| name: ${{ env.VERSION }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.TOKEN }} |