diff --git a/.github/workflows/publish-aur.yml b/.github/workflows/publish-aur.yml index d6dcd558..38e95cdf 100644 --- a/.github/workflows/publish-aur.yml +++ b/.github/workflows/publish-aur.yml @@ -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 @@ -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://aur@aur.archlinux.org/maa-cli.git diff --git a/.github/workflows/publish-homebrew.yml b/.github/workflows/publish-homebrew.yml index 1b19fba0..a33ea6bd 100644 --- a/.github/workflows/publish-homebrew.yml +++ b/.github/workflows/publish-homebrew.yml @@ -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: @@ -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 @@ -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: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec462178..123ba3e6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: | @@ -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 }}