diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index b7c508f..30d6daf 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -6,25 +6,17 @@ on: - main paths-ignore: - ".github/**" + workflow_dispatch: permissions: contents: write jobs: - release: + tag: runs-on: ubuntu-latest + outputs: + new_tag: ${{ steps.bump.outputs.new_tag }} steps: - - name: Get GitHub token - uses: actions/create-github-app-token@v3 - id: get_token - with: - app-id: ${{ secrets.HOSTINGERBOT_APP_ID }} - private-key: ${{ secrets.HOSTINGERBOT_PRIVATE_KEY }} - owner: hostinger - repositories: | - api-cli - homebrew-tap - - name: Repo checkout uses: actions/checkout@v7 with: @@ -37,28 +29,16 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} release_branches: main - - name: Fetch tags - if: steps.bump.outputs.new_tag != '' - run: git fetch --force --tags - - - name: Install Go - uses: actions/setup-go@v7 - with: - go-version-file: 'go.mod' - - - name: Run GoReleaser - if: steps.bump.outputs.new_tag != '' - uses: goreleaser/goreleaser-action@v7 - with: - distribution: goreleaser - version: "~> v2" - args: release --clean - env: - GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} - GORELEASER_CURRENT_TAG: ${{ steps.bump.outputs.new_tag }} + release: + needs: tag + if: needs.tag.outputs.new_tag != '' + uses: ./.github/workflows/release.yaml + secrets: inherit + with: + tag: ${{ needs.tag.outputs.new_tag }} notify-failure: - needs: [release] + needs: [tag, release] if: failure() runs-on: ubuntu-latest steps: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2ec04ce..214b27e 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,6 +2,13 @@ name: release on: workflow_dispatch: + workflow_call: + inputs: + tag: + description: 'Tag to publish; defaults to the tag on the checked-out commit' + required: false + type: string + default: '' permissions: contents: write @@ -10,6 +17,17 @@ jobs: release: runs-on: ubuntu-latest steps: + - name: Get GitHub token + uses: actions/create-github-app-token@v3 + id: get_token + with: + app-id: ${{ secrets.HOSTINGERBOT_APP_ID }} + private-key: ${{ secrets.HOSTINGERBOT_PRIVATE_KEY }} + owner: hostinger + repositories: | + api-cli + homebrew-tap + - name: Repo checkout uses: actions/checkout@v7 with: @@ -27,4 +45,5 @@ jobs: version: "~> v2" args: release --clean env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ steps.get_token.outputs.token }} + GORELEASER_CURRENT_TAG: ${{ inputs.tag }}