From 537b01509b08c34d3f2f9129a097d1bc05f370f9 Mon Sep 17 00:00:00 2001 From: fujiwara Date: Wed, 18 Sep 2024 10:18:59 +0900 Subject: [PATCH] merge tagpr and release workflows. --- .github/workflows/release.yml | 34 ----------------------- .github/workflows/tagpr-release.yml | 43 +++++++++++++++++++++++++++++ .github/workflows/tagpr.yml | 12 -------- 3 files changed, 43 insertions(+), 46 deletions(-) delete mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/tagpr-release.yml delete mode 100644 .github/workflows/tagpr.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index d072db1..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: release - -on: - push: - branches: - - "!**/*" - tags: - - "v*" - workflow_dispatch: - inputs: - tag: - description: "release tag" - required: true - type: string - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ inputs.tag || github.ref }} - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.22 - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 - with: - version: '~> v2' - args: release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/tagpr-release.yml b/.github/workflows/tagpr-release.yml new file mode 100644 index 0000000..cd716fc --- /dev/null +++ b/.github/workflows/tagpr-release.yml @@ -0,0 +1,43 @@ +name: tagpr and release +on: + push: + branches: ["main"] + workflow_dispatch: + inputs: + tag: + description: "release tag" + required: false + type: string + +permissions: + pull-requests: write + packages: write + contents: write + actions: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag || github.ref }} + - uses: Songmu/tagpr@v1 + id: tagpr + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: ${{ github.event_name != 'workflow_dispatch' }} # skip on workflow_dispatch + # after tagpr adds a release tag, or workflow_dispatch, release it + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: "1.22" + if: ${{ steps.tagpr.outputs.tag != '' || github.event_name == 'workflow_dispatch' }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: '~> v2' + args: release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: ${{ steps.tagpr.outputs.tag != '' || github.event_name == 'workflow_dispatch' }} diff --git a/.github/workflows/tagpr.yml b/.github/workflows/tagpr.yml deleted file mode 100644 index fe8ff6a..0000000 --- a/.github/workflows/tagpr.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: tagpr -on: - push: - branches: ["main"] -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: Songmu/tagpr@main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}