build-release #31
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: build-release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| tags: | |
| - "v*" | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| package-macos: | |
| runs-on: macos-14 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Configure | |
| run: cmake -S . -B build | |
| - name: Build | |
| run: cmake --build build -j4 | |
| - name: Test | |
| run: ctest --test-dir build --output-on-failure | |
| - name: Install Staging | |
| run: cmake --install build --prefix "$GITHUB_WORKSPACE/dist/install" | |
| - name: Package | |
| run: cpack --config build/CPackConfig.cmake | |
| - name: Create Source Archive | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| git archive --format=tar.gz --prefix="mtop-${VERSION}/" "$GITHUB_REF_NAME" > "mtop-${VERSION}-source.tar.gz" | |
| - name: Collect Artifacts | |
| run: | | |
| mkdir -p dist/artifacts | |
| shopt -s nullglob | |
| for file in mtop-*.tar.gz; do | |
| mv "$file" dist/artifacts/ | |
| done | |
| find dist -maxdepth 3 -type f | sort | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: mtop-macos-package | |
| path: | | |
| dist/artifacts/* | |
| dist/install/** | |
| - name: Publish GitHub Release Assets | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| files: dist/artifacts/* | |
| refresh-homebrew-formula: | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: package-macos | |
| runs-on: macos-14 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Main | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| - name: Resolve Version | |
| id: version | |
| run: echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Resolve SHA256 | |
| id: sha | |
| run: | | |
| VERSION="${{ steps.version.outputs.value }}" | |
| curl -L -o "/tmp/mtop-${VERSION}-source.tar.gz" "https://github.com/lxrzlyr/mtop/releases/download/v${VERSION}/mtop-${VERSION}-source.tar.gz" | |
| echo "value=$(shasum -a 256 /tmp/mtop-${VERSION}-source.tar.gz | awk '{print $1}')" >> "$GITHUB_OUTPUT" | |
| - name: Update Formula | |
| run: | | |
| python3 ./scripts/update_homebrew_formula.py \ | |
| ./Formula/mtop.rb \ | |
| "${{ steps.version.outputs.value }}" \ | |
| "${{ steps.sha.outputs.value }}" | |
| - name: Commit Formula Refresh | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add Formula/mtop.rb | |
| if git diff --cached --quiet; then | |
| echo "Formula already matches release" | |
| exit 0 | |
| fi | |
| git commit -m "Refresh Formula for v${{ steps.version.outputs.value }}" | |
| git push origin HEAD:main |