Skip to content

Commit

Permalink
Use cargo dist config to configure tag prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Emann committed Apr 10, 2024
1 parent f680491 commit e924dd2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ permissions:
on:
push:
tags:
- 'applesauce-cli*[0-9]+.[0-9]+.[0-9]+*'
- 'applesauce-cli**[0-9]+.[0-9]+.[0-9]+*'
pull_request:

jobs:
Expand Down Expand Up @@ -230,15 +230,56 @@ jobs:
name: artifacts-dist-manifest
path: dist-manifest.json

publish-homebrew-formula:
needs:
- plan
- host
runs-on: "ubuntu-20.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PLAN: ${{ needs.plan.outputs.val }}
GITHUB_USER: "axo bot"
GITHUB_EMAIL: "[email protected]"
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
steps:
- uses: actions/checkout@v4
with:
repository: "Dr-Emann/homebrew-tap"
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
# So we have access to the formula
- name: Fetch local artifacts
uses: actions/download-artifact@v4
with:
pattern: artifacts-*
path: Formula/
merge-multiple: true
# This is extra complex because you can make your Formula name not match your app name
# so we need to find releases with a *.rb file, and publish with that filename.
- name: Commit formula files
run: |
git config --global user.name "${GITHUB_USER}"
git config --global user.email "${GITHUB_EMAIL}"
for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith(".rb")] | any)'); do
filename=$(echo "$release" | jq '.artifacts[] | select(endswith(".rb"))' --raw-output)
name=$(echo "$filename" | sed "s/\.rb$//")
version=$(echo "$release" | jq .app_version --raw-output)
git add "Formula/${filename}"
git commit -m "${name} ${version}"
done
git push
# Create a Github Release while uploading all files to it
announce:
needs:
- plan
- host
- publish-homebrew-formula
# use "always() && ..." to allow us to wait for all publish jobs while
# still allowing individual publish jobs to skip themselves (for prereleases).
# "host" however must run to completion, no skipping allowed!
if: ${{ always() && needs.host.result == 'success' }}
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
runs-on: "ubuntu-20.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ installers = ["shell", "homebrew"]
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin"]
# Publish jobs to run in CI
pr-run-mode = "plan"
# Skip checking whether the specified configuration files are up to date
allow-dirty = ["ci"]
# A GitHub repo to push Homebrew formulas to
tap = "Dr-Emann/homebrew-tap"
# Publish jobs to run in CI
publish-jobs = ["homebrew"]
# Customize the Homebrew formula name
formula = "applesauce"
tag-namespace = "applesauce-cli"

[profile.release]
debug = true
Expand Down

0 comments on commit e924dd2

Please sign in to comment.