2024-02-18 11:16:05 -07:00
|
|
|
#
|
|
|
|
# .github/workflows/release.yml
|
|
|
|
#
|
2024-02-18 12:13:42 -07:00
|
|
|
---
|
2024-02-18 11:16:05 -07:00
|
|
|
name: release
|
2024-03-10 12:24:09 -06: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 11:16:05 -07:00
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types: [published]
|
|
|
|
jobs:
|
2024-03-30 11:34:30 -06:00
|
|
|
start:
|
2024-02-18 11:16:05 -07:00
|
|
|
runs-on: macos-14
|
2024-07-30 18:02:10 -06:00
|
|
|
outputs:
|
|
|
|
dry_run: ${{ steps.dry_run.outputs.dry_run }}
|
|
|
|
mas_version: ${{ steps.mas_version.outputs.mas_version }}
|
|
|
|
release_branch: ${{ steps.release_branch.outputs.release_branch }}
|
2024-02-18 11:16:05 -07:00
|
|
|
steps:
|
2024-03-09 12:32:04 -07: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 09:05:39 -06:00
|
|
|
# https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=published#release
|
2024-03-09 12:32:04 -07:00
|
|
|
- name: 🔈 Log release event
|
2024-03-31 13:16:30 -06:00
|
|
|
# This step will only run for a real 'release' event.
|
2024-03-09 12:32:04 -07: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 09:05:39 -06:00
|
|
|
echo "release.tag_name: ${{ github.event.release.tag_name }}"
|
|
|
|
echo "release.target_commitish: ${{ github.event.release.target_commitish }}"
|
2024-03-31 08:11:22 -06:00
|
|
|
echo -e "release.body: \n${{ github.event.release.body }}"
|
|
|
|
|
2024-07-30 18:02:10 -06: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 09:05:39 -06:00
|
|
|
|
2024-07-30 18:02:10 -06:00
|
|
|
- id: release_branch
|
2024-03-09 12:32:04 -07:00
|
|
|
run: |
|
2024-07-30 18:02:10 -06:00
|
|
|
echo "RELEASE_BRANCH=releases/release-${{ github.event.release.tag_name }}" >>"$GITHUB_OUTPUT"
|
|
|
|
|
2024-07-30 17:53:50 -06:00
|
|
|
prepare-release:
|
2024-07-29 18:05:50 -06:00
|
|
|
runs-on: macos-14
|
|
|
|
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-30 20:27:03 -06:00
|
|
|
- name: 👢 Bootstrap
|
|
|
|
run: |
|
|
|
|
script/bootstrap -f
|
|
|
|
|
2024-07-30 17:53:50 -06:00
|
|
|
- name: 🔀 Create release branch
|
2024-07-30 18:02:10 -06:00
|
|
|
env:
|
|
|
|
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
|
2024-07-29 18:05:50 -06:00
|
|
|
run: |
|
2024-07-30 20:11:01 -06:00
|
|
|
git branch "${RELEASE_BRANCH}"
|
|
|
|
git switch "${RELEASE_BRANCH}"
|
2024-07-29 18:05:50 -06:00
|
|
|
|
2024-07-30 17:53:50 -06:00
|
|
|
- name: 🔖 Update version
|
2024-07-30 18:02:10 -06:00
|
|
|
env:
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
2024-07-30 17:53:50 -06:00
|
|
|
run: |
|
2024-07-30 21:18:37 -06:00
|
|
|
script/version_bump "${MAS_VERSION}"
|
2024-07-29 18:05:50 -06:00
|
|
|
|
2024-07-30 17:53:50 -06:00
|
|
|
- name: 💾 Commit changes
|
2024-07-30 18:02:10 -06:00
|
|
|
env:
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
2024-07-30 20:36:16 -06:00
|
|
|
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
|
2024-07-30 17:53:50 -06:00
|
|
|
run: |
|
|
|
|
git add \
|
|
|
|
"Homebrew/mas.rb" \
|
|
|
|
"Homebrew/mas-tap.rb" \
|
|
|
|
"Sources/MasKit/Package.swift"
|
|
|
|
git commit \
|
2024-07-30 20:11:01 -06:00
|
|
|
--message="🔖 Version ${MAS_VERSION}"
|
2024-07-30 20:36:16 -06:00
|
|
|
git push \
|
|
|
|
--set-upstream origin "${RELEASE_BRANCH}"
|
2024-07-30 17:53:50 -06:00
|
|
|
|
|
|
|
- name: ⤴️ Open PR
|
|
|
|
env:
|
2024-07-30 20:42:10 -06:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-07-30 18:02:10 -06:00
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
|
|
|
RELEASE_BRANCH: ${{ needs.start.outputs.release_branch }}
|
2024-07-30 17:53:50 -06:00
|
|
|
run: |
|
|
|
|
gh pr create \
|
2024-07-30 21:34:30 -06:00
|
|
|
--assignee phatblat \
|
2024-07-30 17:53:50 -06:00
|
|
|
--base main \
|
2024-07-30 21:34:30 -06:00
|
|
|
--draft \
|
2024-07-30 20:11:01 -06:00
|
|
|
--head "${RELEASE_BRANCH}" \
|
|
|
|
--title "🔖 Version ${MAS_VERSION}" \
|
|
|
|
--body "This PR contains the changes from releasing version [${MAS_VERSION}](https://github.com/mas-cli/mas/releases/tag/${MAS_VERSION})."
|
2024-07-29 18:05:50 -06:00
|
|
|
|
2024-03-10 19:32:02 -06:00
|
|
|
pkg-installer:
|
|
|
|
runs-on: macos-14
|
2024-07-30 18:02:10 -06:00
|
|
|
needs: [start, prepare-release]
|
2024-03-10 19:32:02 -06:00
|
|
|
steps:
|
2024-02-18 12:13:42 -07:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
# A fetch-depth of 0 includes all history and tags for script/version
|
|
|
|
fetch-depth: 0
|
2024-07-30 20:47:28 -06:00
|
|
|
ref: ${{ needs.start.outputs.release_branch }}
|
2024-03-10 19:32:02 -06:00
|
|
|
|
2024-02-18 20:14:31 -07:00
|
|
|
- name: 👢 Bootstrap
|
2024-03-10 11:19:12 -06:00
|
|
|
run: |
|
2024-03-30 11:03:55 -06:00
|
|
|
script/bootstrap -f
|
2024-02-18 19:45:04 -07:00
|
|
|
|
|
|
|
# Important to trigger a universal build first as package just works with
|
|
|
|
# the `mas` binary in finds in the build dir.
|
2024-02-18 20:14:31 -07:00
|
|
|
- name: 🏗️ Build Universal
|
2024-03-10 11:19:12 -06:00
|
|
|
run: |
|
|
|
|
script/build --universal
|
2024-03-10 19:32:02 -06:00
|
|
|
|
2024-02-18 20:14:31 -07:00
|
|
|
- name: 📦 macOS Package
|
2024-03-10 11:19:12 -06:00
|
|
|
run: |
|
|
|
|
script/package
|
2024-03-10 19:32:02 -06:00
|
|
|
|
2024-02-18 20:14:31 -07:00
|
|
|
- name: 🚀 Upload mas.pkg
|
2024-07-30 18:02:10 -06:00
|
|
|
env:
|
2024-07-30 20:42:10 -06:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-07-30 18:02:10 -06: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 13:16:30 -06:00
|
|
|
run: |
|
2024-07-30 20:11:01 -06:00
|
|
|
gh release upload ${MAS_VERSION} \
|
2024-03-31 13:16:30 -06:00
|
|
|
.build/mas.pkg
|
2024-02-18 19:45:04 -07:00
|
|
|
|
2024-07-29 17:16:25 -06:00
|
|
|
homebrew-tap:
|
2024-03-10 19:32:02 -06:00
|
|
|
runs-on: macos-14
|
2024-07-30 18:02:10 -06:00
|
|
|
needs: [start, prepare-release]
|
2024-03-10 19:32:02 -06:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
# A fetch-depth of 0 includes all history and tags for script/version
|
|
|
|
fetch-depth: 0
|
2024-07-30 20:47:28 -06:00
|
|
|
ref: ${{ needs.start.outputs.release_branch }}
|
2024-03-10 19:32:02 -06:00
|
|
|
|
|
|
|
- name: 👢 Bootstrap
|
|
|
|
run: |
|
2024-03-30 11:03:55 -06:00
|
|
|
script/bootstrap -f
|
2024-03-10 19:32:02 -06:00
|
|
|
|
2024-07-29 17:16:25 -06:00
|
|
|
- name: 🚰 Update mas tap formula
|
2024-07-30 18:02:10 -06:00
|
|
|
env:
|
2024-07-30 21:28:43 -06:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-07-30 18:02:10 -06:00
|
|
|
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
2024-03-10 11:22:09 -06:00
|
|
|
run: |
|
2024-07-30 20:11:01 -06:00
|
|
|
DRY_RUN=${DRY_RUN} \
|
|
|
|
script/brew_tap_update ${MAS_VERSION}
|
2024-03-10 19:32:02 -06:00
|
|
|
|
2024-07-29 17:16:25 -06:00
|
|
|
- name: 🚀 Upload Bottles
|
2024-07-30 18:02:10 -06:00
|
|
|
env:
|
2024-07-30 20:42:10 -06:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-07-30 18:02:10 -06: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 17:16:25 -06:00
|
|
|
run: |
|
2024-07-30 20:11:01 -06:00
|
|
|
gh release upload ${MAS_VERSION} \
|
2024-07-29 17:16:25 -06:00
|
|
|
.build/bottles/mas-*.bottle.tar.gz
|
|
|
|
|
|
|
|
homebrew-core:
|
2024-03-10 19:32:02 -06:00
|
|
|
runs-on: macos-14
|
2024-07-30 18:02:10 -06:00
|
|
|
needs: [start, prepare-release, homebrew-tap]
|
2024-03-10 19:32:02 -06:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
# A fetch-depth of 0 includes all history and tags for script/version
|
|
|
|
fetch-depth: 0
|
2024-07-30 20:47:28 -06:00
|
|
|
ref: ${{ needs.start.outputs.release_branch }}
|
2024-03-10 19:32:02 -06:00
|
|
|
|
|
|
|
- name: 👢 Bootstrap
|
|
|
|
run: |
|
2024-03-30 11:03:55 -06:00
|
|
|
script/bootstrap -f
|
2024-03-10 19:32:02 -06:00
|
|
|
|
2024-07-29 17:16:25 -06:00
|
|
|
- name: 🍺 Update Homebrew mas formula
|
2024-07-30 18:02:10 -06:00
|
|
|
env:
|
2024-07-30 21:36:18 -06:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-07-30 18:02:10 -06:00
|
|
|
DRY_RUN: ${{ needs.start.outputs.dry_run }}
|
|
|
|
MAS_VERSION: ${{ needs.start.outputs.mas_version }}
|
2024-03-10 19:32:02 -06:00
|
|
|
run: |
|
2024-07-30 20:11:01 -06:00
|
|
|
DRY_RUN=${DRY_RUN} \
|
|
|
|
script/brew_core_update ${MAS_VERSION}
|
2024-03-10 19:32:02 -06:00
|
|
|
|