diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml new file mode 100644 index 0000000..0a03b6a --- /dev/null +++ b/.github/actions/release/action.yml @@ -0,0 +1,21 @@ +name: release +inputs: + github-token: + required: true + homebrew-tap-github-token: + required: true +runs: + using: composite + steps: + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ inputs.github-token }} + HOMEBREW_TAP_GITHUB_TOKEN: ${{ inputs.homebrew-tap-github-token }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5607844..7016275 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,8 @@ on: - "v[0-9]+.[0-9]+.[0-9]+" branches: - "*" + branches-ignore: + - "tagpr.*" pull_request: types: - opened @@ -25,7 +27,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.21 + go-version-file: go.mod id: go - name: Cache uses: actions/cache@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3389f47..54ead4d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,4 @@ +# for manual release (No triggering when tagpr is used.) name: release on: push: @@ -11,15 +12,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup Go - uses: actions/setup-go@v5 + - uses: ./.github/actions/release with: - go-version: 1.21 - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v5 - with: - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} + homebrew-tap-github-token: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} diff --git a/.github/workflows/tagpr.yaml b/.github/workflows/tagpr.yaml new file mode 100644 index 0000000..6e6dcee --- /dev/null +++ b/.github/workflows/tagpr.yaml @@ -0,0 +1,23 @@ +name: tagpr +on: + push: + branches: + - "main" +jobs: + tagpr: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: tagpr + id: tagpr + uses: Songmu/tagpr@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: ./.github/actions/release + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + homebrew-tap-github-token: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + if: "steps.tagpr.outputs.tag != ''" \ No newline at end of file