Skip to content

Commit

Permalink
ci: call publish workflows after release
Browse files Browse the repository at this point in the history
  • Loading branch information
wangl-cc committed Oct 7, 2023
1 parent 8e04ff7 commit c4b6878
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 29 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/publish-aur.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,35 @@ name: Publish AUR Package
on:
release:
types: [published]
workflow_call:
inputs:
pkgver:
description: Package version
required: false
type: string
pkgrel:
description: Package release number
default: 1
required: false
type: number
dryrun:
description: Do not push changes to AUR
default: true
required: true
type: boolean
workflow_dispatch:
inputs:
pkgver:
description: Package version
required: false
type: string
pkgrel:
description: Package release number
default: 1
required: false
type: number
dryrun:
description: 'Do not push changes to aur'
description: Do not push changes to AUR
default: true
required: true
type: boolean
Expand All @@ -37,7 +55,7 @@ jobs:
install -m700 <(echo '${{ secrets.AUR_SSH_PRIVATE_KEY }}') id_rsa
install -m700 <(ssh-keyscan -H aur.archlinux.org) known_hosts
- name: Fetch from aur
- name: Fetch from AUR
run: |
git clone ssh://[email protected]/maa-cli.git
Expand Down
48 changes: 25 additions & 23 deletions .github/workflows/publish-homebrew.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,28 @@ name: Publish Homebrew
on:
release:
types: [published]
workflow_call:
inputs:
version:
description: Package version
required: false
type: string
dryrun:
description: Do not push changes to Homebrew
default: true
required: true
type: boolean
workflow_dispatch:
inputs:
version:
description: Package version
required: false
type: string
dryrun:
description: Do not push changes to Homebrew
default: true
required: true
type: boolean

defaults:
run:
Expand All @@ -12,28 +34,6 @@ permissions:
contents: read

jobs:
meta:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Version
id: version
run: |
CARGO_VERSION=$(yq -oy ".package.version" maa-cli/Cargo.toml)
# check if version is equal to tag if not PR
if [ "$GITHUB_EVENT_NAME" != "pull_request" ]; then
REF=${{ github.ref }}
REF_VERSION=${REF#refs/tags/v}
if [ "$REF_VERSION" != "$CARGO_VERSION" ]; then
echo "Version mismatch: $REF_VERSION != $CARGO_VERSION"
fi
fi
echo "Version: $CARGO_VERSION"
echo "version=$CARGO_VERSION" >> $GITHUB_OUTPUT
bump-cask:
name: Bump Cask and Open PR
runs-on: macos-latest
Expand All @@ -45,12 +45,14 @@ jobs:
token: ${{secrets.MAA_HOMEBREW_BUMP_PR}}
tap: MaaAssistantArknights/homebrew-tap
cask: maa-cli-bin
tag: v${{ needs.meta.outputs.version }}
tag: ${{ inputs.version || github.ref }}
no_fork: true
force: false
dryrun: $${ inputs.dryrun || false }

bump-formula:
name: Bump Formula and Open PR
if: ${{ inputs.dryrun || false }}
runs-on: macos-latest
needs: [meta]
steps:
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ jobs:
dryrun=true
fi
echo "dryrun=$dryrun" >> $GITHUB_OUTPUT
- name: If Dryrun
if: ${{ fromJson(steps.dryrun.outputs.dryrun) }}
run: |
echo "Dryrun"
- name: Get Version
id: version
run: |
Expand Down Expand Up @@ -205,3 +201,19 @@ jobs:
echo '```' >> $GITHUB_STEP_SUMMARY
git commit version.json -m "Update version.json"
git push --verbose ${{ fromJson(needs.meta.outputs.dryrun) && '--dry-run' || ''}}
publish-homebrew:
needs: [meta, release]
name: Publish Homebrew Formula and Cask
if: ${{ !fromJson(needs.meta.outputs.dryrun) }}
uses: ./.github/workflows/publish-homebrew.yml

publish-aur:
needs: [meta, release]
name: Publish AUR Package
uses: ./.github/workflows/publish-aur.yml
with:
pkgver: ${{ needs.meta.outputs.version }}
dryrun: ${{ fromJson(needs.meta.outputs.dryrun) }}
secrets:
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}

0 comments on commit c4b6878

Please sign in to comment.