2024-02-18 18:16:05 +00:00
|
|
|
#
|
|
|
|
# .github/workflows/release.yml
|
|
|
|
#
|
2024-02-18 19:13:42 +00:00
|
|
|
---
|
2024-02-18 18:16:05 +00:00
|
|
|
name: release
|
2024-03-10 18:24:09 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
# Prefixes all `run` commands with the following command to force them to run outside Rosetta.
|
|
|
|
shell: arch -arm64 bash --noprofile --norc -eo pipefail {0}
|
2024-02-18 18:16:05 +00:00
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: [published]
|
|
|
|
jobs:
|
2024-03-30 17:34:30 +00:00
|
|
|
start:
|
2024-10-27 03:48:05 +00:00
|
|
|
runs-on: macos-15
|
2024-07-31 00:02:10 +00:00
|
|
|
outputs:
|
|
|
|
dry_run: ${{ steps.dry_run.outputs.dry_run }}
|
|
|
|
mas_version: ${{ steps.mas_version.outputs.mas_version }}
|
2024-11-03 20:10:41 +00:00
|
|
|
pre_release: ${{ steps.pre_release.outputs.pre_release }}
|
2024-07-31 00:02:10 +00:00
|
|
|
release_branch: ${{ steps.release_branch.outputs.release_branch }}
|
2024-02-18 18:16:05 +00:00
|
|
|
steps:
|
2024-03-09 19:32:04 +00:00
|
|
|
# Logs event details and sets `DRY_RUN` env var
|
|
|
|
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
|
2024-03-10 15:05:39 +00:00
|
|
|
# https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=published#release
|
2024-03-09 19:32:04 +00:00
|
|
|
- name: 🔈 Log release event
|
2024-03-31 19:16:30 +00:00
|
|
|
# This step will only run for a real 'release' event.
|
2024-03-09 19:32:04 +00:00
|
|
|
if: ${{ github.event.release.name != '' }}
|
|
|
|
run: |
|
|
|
|
echo "Triggered by a release publication event (wet run)"
|
|
|
|
echo "release.name: ${{ github.event.release.name }}"
|
2024-03-10 15:05:39 +00:00
|
|
|
echo "release.tag_name: ${{ github.event.release.tag_name }}"
|
|
|
|
echo "release.target_commitish: ${{ github.event.release.target_commitish }}"
|
2024-03-31 14:11:22 +00:00
|
|
|
echo -e "release.body: \n${{ github.event.release.body }}"
|
|
|
|
|
2024-07-31 00:02:10 +00:00
|
|
|
- id: dry_run
|
|
|
|
run: |
|
|
|
|
echo "DRY_RUN=false" >>"$GITHUB_OUTPUT"
|
|
|
|
|
|
|
|
- id: mas_version
|
|
|
|
run: |
|
|
|
|
echo "MAS_VERSION=${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
|
2024-03-10 15:05:39 +00:00
|
|
|
|
2024-11-03 19:17:31 +00:00
|
|
|
- id: pre_release
|
|
|
|
run: |
|
2024-11-03 20:10:41 +00:00
|
|
|
echo "PRE_RELEASE=$(grep -q '-' <<<$MAS_VERSION && echo 'true' || echo 'false')" >>"$GITHUB_OUTPUT"
|
2024-11-03 19:17:31 +00:00
|
|
|
|
2024-07-31 00:02:10 +00:00
|
|
|
- id: release_branch
|
2024-03-09 19:32:04 +00:00
|
|
|
run: |
|
2024-07-31 00:02:10 +00:00
|
|
|
echo "RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
|
|
|
|
|
2024-07-30 23:53:50 +00:00
|
|
|
prepare-release:
|
2024-10-27 03:48:05 +00:00
|
|
|
runs-on: macos-15
|
2024-07-30 00:05:50 +00:00
|
|
|
needs: [start]
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
# A fetch-depth of 0 includes all history and tags for script/version
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2024-07-31 02:27:03 +00:00
|
|
|
- name: 👢 Bootstrap
|
|
|
|
run: |
|
|
|
|
script/bootstrap -f
|
|
|
|
|
2024-08-01 03:04:54 +00:00
|
|
|
- name: 🔀 Create mas release branch
|
2024-07-31 00:02:10 +00:00
|
|
|
env:
|
|
|
|
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
|
2024-07-30 00:05:50 +00:00
|
|
|
run: |
|
2024-07-31 02:11:01 +00:00
|
|
|
git branch "${RELEASE_BRANCH}"
|
|
|
|
git switch "${RELEASE_BRANCH}"
|
2024-07-30 00:05:50 +00:00
|
|
|
|
2024-07-30 23:53:50 +00:00
|
|
|
- name: 🔖 Update version
|
2024-07-31 00:02:10 +00:00
|
|
|
env:
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
2024-07-30 23:53:50 +00:00
|
|
|
run: |
|
2024-07-31 03:18:37 +00:00
|
|
|
script/version_bump "${MAS_VERSION}"
|
2024-07-30 00:05:50 +00:00
|
|
|
|
2024-11-03 17:28:10 +00:00
|
|
|
- name: 🔧 Configure Git Author
|
|
|
|
run: |
|
|
|
|
git config --global user.name 'masclibot'
|
|
|
|
git config --global user.email 'masclibot@users.noreply.github.com'
|
|
|
|
|
2024-07-30 23:53:50 +00:00
|
|
|
- name: 💾 Commit changes
|
2024-07-31 00:02:10 +00:00
|
|
|
env:
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
2024-07-31 02:36:16 +00:00
|
|
|
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
|
2024-07-30 23:53:50 +00:00
|
|
|
run: |
|
|
|
|
git add \
|
|
|
|
"Homebrew/mas.rb" \
|
|
|
|
"Homebrew/mas-tap.rb" \
|
2024-11-03 17:18:35 +00:00
|
|
|
"Package.swift"
|
2024-07-30 23:53:50 +00:00
|
|
|
git commit \
|
2024-07-31 02:11:01 +00:00
|
|
|
--message="🔖 Version ${MAS_VERSION}"
|
2024-07-31 02:36:16 +00:00
|
|
|
git push \
|
|
|
|
--set-upstream origin "${RELEASE_BRANCH}"
|
2024-07-30 23:53:50 +00:00
|
|
|
|
2024-03-11 01:32:02 +00:00
|
|
|
pkg-installer:
|
2024-10-27 03:48:05 +00:00
|
|
|
runs-on: macos-15
|
2024-07-31 00:02:10 +00:00
|
|
|
needs: [start, prepare-release]
|
2024-03-11 01:32:02 +00:00
|
|
|
steps:
|
2024-02-18 19:13:42 +00:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
# A fetch-depth of 0 includes all history and tags for script/version
|
|
|
|
fetch-depth: 0
|
2024-07-31 02:47:28 +00:00
|
|
|
ref: ${{ needs.start.outputs.release_branch }}
|
2024-03-11 01:32:02 +00:00
|
|
|
|
2024-02-19 03:14:31 +00:00
|
|
|
- name: 👢 Bootstrap
|
2024-03-10 17:19:12 +00:00
|
|
|
run: |
|
2024-03-30 17:03:55 +00:00
|
|
|
script/bootstrap -f
|
2024-02-19 02:45:04 +00:00
|
|
|
|
|
|
|
# Important to trigger a universal build first as package just works with
|
|
|
|
# the `mas` binary in finds in the build dir.
|
2024-02-19 03:14:31 +00:00
|
|
|
- name: 🏗️ Build Universal
|
2024-03-10 17:19:12 +00:00
|
|
|
run: |
|
|
|
|
script/build --universal
|
2024-03-11 01:32:02 +00:00
|
|
|
|
2024-02-19 03:14:31 +00:00
|
|
|
- name: 📦 macOS Package
|
2024-03-10 17:19:12 +00:00
|
|
|
run: |
|
|
|
|
script/package
|
2024-03-11 01:32:02 +00:00
|
|
|
|
2024-02-19 03:14:31 +00:00
|
|
|
- name: 🚀 Upload mas.pkg
|
2024-07-31 00:02:10 +00:00
|
|
|
env:
|
2024-07-31 02:42:10 +00:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-07-31 00:02:10 +00:00
|
|
|
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
|
|
|
if: ${{ needs.start.outputs.dry_run == 'false' }}
|
2024-03-31 19:16:30 +00:00
|
|
|
run: |
|
2024-07-31 02:11:01 +00:00
|
|
|
gh release upload ${MAS_VERSION} \
|
2024-03-31 19:16:30 +00:00
|
|
|
.build/mas.pkg
|
2024-02-19 02:45:04 +00:00
|
|
|
|
2024-07-29 23:16:25 +00:00
|
|
|
homebrew-tap:
|
2024-10-27 03:48:05 +00:00
|
|
|
runs-on: macos-15
|
2024-07-31 00:02:10 +00:00
|
|
|
needs: [start, prepare-release]
|
2024-03-11 01:32:02 +00:00
|
|
|
steps:
|
2024-08-03 18:20:40 +00:00
|
|
|
- name: 📺 Checkout mas repo
|
|
|
|
uses: actions/checkout@v4
|
2024-03-11 01:32:02 +00:00
|
|
|
with:
|
|
|
|
# A fetch-depth of 0 includes all history and tags for script/version
|
|
|
|
fetch-depth: 0
|
2024-07-31 02:47:28 +00:00
|
|
|
ref: ${{ needs.start.outputs.release_branch }}
|
2024-03-11 01:32:02 +00:00
|
|
|
|
|
|
|
- name: 👢 Bootstrap
|
|
|
|
run: |
|
2024-03-30 17:03:55 +00:00
|
|
|
script/bootstrap -f
|
2024-03-11 01:32:02 +00:00
|
|
|
|
2024-10-13 16:29:37 +00:00
|
|
|
# The mas-cli/homebrew-tap repo needs to be checked out using the current
|
|
|
|
# GitHub credentials in order to open a PR. However, the `brew tap` command
|
|
|
|
# must be run for Homebrew to see the dir as a tap.
|
2024-08-03 20:47:08 +00:00
|
|
|
# This is necessary to avoid the following error:
|
|
|
|
# Error: No available formula or cask with the name "mas-cli/tap/mas".
|
2024-08-03 18:20:40 +00:00
|
|
|
- name: 🚰 Checkout mas tap
|
2024-08-03 20:47:08 +00:00
|
|
|
run: |
|
2024-10-13 16:29:37 +00:00
|
|
|
rm -rf /opt/homebrew/Library/Taps
|
2024-10-13 16:38:46 +00:00
|
|
|
mkdir Taps
|
2024-10-20 17:53:37 +00:00
|
|
|
ln -s $(realpath Taps) /opt/homebrew/Library/Taps
|
2024-10-13 16:38:46 +00:00
|
|
|
ls -l /opt/homebrew/Library/Taps
|
|
|
|
brew tap mas-cli/tap
|
2024-10-13 16:35:00 +00:00
|
|
|
brew tap
|
2024-08-03 20:47:08 +00:00
|
|
|
|
|
|
|
# Checkout with a token for write access
|
|
|
|
- name: 🚰 Re-clone mas tap
|
2024-08-03 18:20:40 +00:00
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
2024-08-03 18:36:15 +00:00
|
|
|
repository: mas-cli/homebrew-tap
|
|
|
|
token: ${{ secrets.DEPLOY_TOKEN }}
|
2024-08-03 20:47:08 +00:00
|
|
|
# brew --repository mas-cli/tap
|
2024-08-03 20:58:54 +00:00
|
|
|
path: Taps/mas-cli/homebrew-tap
|
2024-08-03 18:20:40 +00:00
|
|
|
|
2024-11-03 17:28:10 +00:00
|
|
|
- name: 🔧 Configure Git Author
|
|
|
|
run: |
|
|
|
|
git config --global user.name 'masclibot'
|
|
|
|
git config --global user.email 'masclibot@users.noreply.github.com'
|
|
|
|
|
2024-08-01 03:04:54 +00:00
|
|
|
- name: ⤴️ Open mas tap PR
|
2024-07-31 03:51:32 +00:00
|
|
|
env:
|
2024-08-03 18:20:40 +00:00
|
|
|
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
2024-07-31 03:51:32 +00:00
|
|
|
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
2024-07-31 03:56:07 +00:00
|
|
|
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
|
2024-07-31 03:51:32 +00:00
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
2024-08-03 20:47:08 +00:00
|
|
|
working-directory: /opt/homebrew/Library/Taps/mas-cli/homebrew-tap
|
2024-07-31 03:51:32 +00:00
|
|
|
run: |
|
2024-08-01 03:04:54 +00:00
|
|
|
git branch "${RELEASE_BRANCH}"
|
|
|
|
git switch "${RELEASE_BRANCH}"
|
|
|
|
|
|
|
|
cp -v \
|
|
|
|
${GITHUB_WORKSPACE}/Homebrew/mas-tap.rb \
|
|
|
|
Formula/mas.rb
|
|
|
|
|
|
|
|
git add Formula/mas.rb
|
|
|
|
git commit --message="🔖 Version ${MAS_VERSION}"
|
|
|
|
|
2024-08-03 18:20:40 +00:00
|
|
|
git push \
|
|
|
|
--set-upstream origin "${RELEASE_BRANCH}"
|
|
|
|
|
2024-07-31 03:51:32 +00:00
|
|
|
gh pr create \
|
|
|
|
--assignee phatblat \
|
|
|
|
--base main \
|
2024-07-31 03:56:07 +00:00
|
|
|
--head "${RELEASE_BRANCH}" \
|
2024-07-31 03:51:32 +00:00
|
|
|
--title "🔖 Version ${MAS_VERSION}" \
|
2024-11-03 18:38:06 +00:00
|
|
|
--body "This PR contains the changes from releasing version \
|
|
|
|
[${MAS_VERSION}](https://github.com/mas-cli/mas/releases/tag/${MAS_VERSION})."
|
2024-07-31 03:51:32 +00:00
|
|
|
|
2024-08-01 03:04:54 +00:00
|
|
|
- name: 🚰 Update mas tap formula
|
|
|
|
env:
|
|
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
|
|
|
run: |
|
|
|
|
DRY_RUN=${DRY_RUN} \
|
|
|
|
script/brew_tap_update ${MAS_VERSION}
|
|
|
|
|
2024-07-29 23:16:25 +00:00
|
|
|
- name: 🚀 Upload Bottles
|
2024-07-31 00:02:10 +00:00
|
|
|
env:
|
2024-07-31 02:42:10 +00:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-07-31 00:02:10 +00:00
|
|
|
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
|
|
|
if: ${{ needs.start.outputs.dry_run == 'false' }}
|
2024-07-29 23:16:25 +00:00
|
|
|
run: |
|
2024-07-31 02:11:01 +00:00
|
|
|
gh release upload ${MAS_VERSION} \
|
2024-07-29 23:16:25 +00:00
|
|
|
.build/bottles/mas-*.bottle.tar.gz
|
|
|
|
|
|
|
|
homebrew-core:
|
2024-10-27 03:48:05 +00:00
|
|
|
runs-on: macos-15
|
2024-07-31 00:02:10 +00:00
|
|
|
needs: [start, prepare-release, homebrew-tap]
|
2024-11-03 19:25:25 +00:00
|
|
|
env:
|
|
|
|
PRE_RELEASE: ${{ needs.start.outputs.pre_release }}
|
2024-03-11 01:32:02 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
2024-11-03 19:25:25 +00:00
|
|
|
if: env.PRE_RELEASE == 'false'
|
2024-03-11 01:32:02 +00:00
|
|
|
with:
|
|
|
|
# A fetch-depth of 0 includes all history and tags for script/version
|
|
|
|
fetch-depth: 0
|
2024-07-31 02:47:28 +00:00
|
|
|
ref: ${{ needs.start.outputs.release_branch }}
|
2024-03-11 01:32:02 +00:00
|
|
|
|
|
|
|
- name: 👢 Bootstrap
|
2024-11-03 19:25:25 +00:00
|
|
|
if: env.PRE_RELEASE == 'false'
|
2024-03-11 01:32:02 +00:00
|
|
|
run: |
|
2024-03-30 17:03:55 +00:00
|
|
|
script/bootstrap -f
|
2024-03-11 01:32:02 +00:00
|
|
|
|
2024-11-03 17:28:10 +00:00
|
|
|
- name: 🔧 Configure Git Author
|
2024-11-03 19:25:25 +00:00
|
|
|
if: env.PRE_RELEASE == 'false'
|
2024-11-03 17:28:10 +00:00
|
|
|
run: |
|
|
|
|
git config --global user.name 'masclibot'
|
|
|
|
git config --global user.email 'masclibot@users.noreply.github.com'
|
|
|
|
|
2024-07-29 23:16:25 +00:00
|
|
|
- name: 🍺 Update Homebrew mas formula
|
2024-07-31 00:02:10 +00:00
|
|
|
env:
|
2024-07-31 03:36:18 +00:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-11-03 18:51:53 +00:00
|
|
|
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
|
2024-07-31 00:02:10 +00:00
|
|
|
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
2024-11-03 19:25:25 +00:00
|
|
|
if: env.PRE_RELEASE == 'false'
|
2024-03-11 01:32:02 +00:00
|
|
|
run: |
|
2024-07-31 02:11:01 +00:00
|
|
|
DRY_RUN=${DRY_RUN} \
|
|
|
|
script/brew_core_update ${MAS_VERSION}
|