|
| 1 | +name: Release |
| 2 | + |
| 3 | +# Tag a release and everything else is automatic: this publishes the GitHub release and |
| 4 | +# bumps the Homebrew formula (url + version + sha256) so `brew install/upgrade devkit` |
| 5 | +# always tracks the latest tag. The only manual step is `git tag vX.Y.Z && git push --tags`. |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + |
| 17 | + - name: Compute version and source-tarball sha256 |
| 18 | + id: meta |
| 19 | + env: |
| 20 | + TAG: ${{ github.ref_name }} |
| 21 | + REPO: ${{ github.repository }} |
| 22 | + run: | |
| 23 | + VERSION="${TAG#v}" |
| 24 | + URL="https://github.com/$REPO/archive/refs/tags/$TAG.tar.gz" |
| 25 | + # The tag archive can lag a few seconds behind the tag push; retry briefly. |
| 26 | + SHA="" |
| 27 | + for _ in 1 2 3 4 5 6; do |
| 28 | + SHA=$(curl -fsSL "$URL" | shasum -a 256 | awk '{print $1}') || SHA="" |
| 29 | + [ -n "$SHA" ] && break |
| 30 | + sleep 5 |
| 31 | + done |
| 32 | + [ -n "$SHA" ] || { echo "::error::could not compute sha256 for $URL"; exit 1; } |
| 33 | + { |
| 34 | + echo "version=$VERSION" |
| 35 | + echo "url=$URL" |
| 36 | + echo "sha256=$SHA" |
| 37 | + } >> "$GITHUB_OUTPUT" |
| 38 | +
|
| 39 | + - name: Publish GitHub release |
| 40 | + env: |
| 41 | + GH_TOKEN: ${{ github.token }} |
| 42 | + TAG: ${{ github.ref_name }} |
| 43 | + REPO: ${{ github.repository }} |
| 44 | + VERSION: ${{ steps.meta.outputs.version }} |
| 45 | + run: | |
| 46 | + gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1 \ |
| 47 | + || gh release create "$TAG" --repo "$REPO" --title "devkit $VERSION" --generate-notes |
| 48 | +
|
| 49 | + - name: Bump Homebrew formula |
| 50 | + env: |
| 51 | + GH_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} |
| 52 | + VERSION: ${{ steps.meta.outputs.version }} |
| 53 | + URL: ${{ steps.meta.outputs.url }} |
| 54 | + SHA256: ${{ steps.meta.outputs.sha256 }} |
| 55 | + run: | |
| 56 | + git clone "https://x-access-token:${GH_TOKEN}@github.com/djadmin/homebrew-tap.git" |
| 57 | + cd homebrew-tap |
| 58 | + # Update only the CLI formula (devkit.rb); the app cask lives in Casks/ and is |
| 59 | + # released from the devkit-app repo. |
| 60 | + sed -i "s|^ url \".*\"| url \"$URL\"|" devkit.rb |
| 61 | + sed -i "s|^ sha256 \".*\"| sha256 \"$SHA256\"|" devkit.rb |
| 62 | + sed -i "s|^ version \".*\"| version \"$VERSION\"|" devkit.rb |
| 63 | + git config user.email "ci@devkit" |
| 64 | + git config user.name "devkit-ci" |
| 65 | + git add devkit.rb |
| 66 | + git diff --staged --quiet || git commit -m "devkit $VERSION" |
| 67 | + git push |
0 commit comments