From 93f4be9305056e7c67f6cadeca1f7809a17efb88 Mon Sep 17 00:00:00 2001 From: Luca Lanziani Date: Tue, 26 Sep 2023 10:35:35 +0200 Subject: [PATCH] feat: unify all release steps in a single pipeline (#113) --- .github/workflows/release-please.yaml | 50 ++++++++++++++++----------- .github/workflows/release.yml | 35 ------------------- 2 files changed, 29 insertions(+), 56 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 9263ad8..362913a 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -3,37 +3,45 @@ on: branches: - main -permissions: - contents: write - pull-requests: write - name: release-please jobs: release-please: + permissions: + pull-requests: write + contents: write + id-token: write runs-on: ubuntu-latest steps: - - uses: tibdex/github-app-token@v1.7.0 - id: get_installation_token - with: - app_id: ${{ secrets.RELEASE_PLEASE_APP_ID }} - installation_id: ${{ secrets.RELEASE_PLEASE_APP_INSTALLATION_ID }} - private_key: ${{ secrets.RELEASE_PLEASE_APP_PRIVATE_KEY }} - + ## Build a release based on the release-please-config.json file - uses: google-github-actions/release-please-action@v3 id: release with: command: manifest - token: ${{ steps.get_installation_token.outputs.token }} - # The logic below handles the npm publication - - uses: actions/checkout@v2 + ## Build go binary and add it to the release + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + if: ${{ steps.release.outputs.release_created }} + + - uses: actions/setup-go@v4 + with: + go-version: stable + if: ${{ steps.release.outputs.release_created }} + + - name: Build go binaries + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: ${{ steps.release.outputs.release_created }} - # The logic below handles the npm publication: - - uses: actions/checkout@v2 - # these if statements ensure that a publication only occurs when - # a new release is created: + ## Publish the release to npm + - uses: actions/checkout@v4 if: ${{ steps.release.outputs.release_created }} - name: Get commit author @@ -51,9 +59,9 @@ jobs: node-version: "18.x" registry-url: "https://registry.npmjs.org" if: ${{ steps.release.outputs.release_created }} - - # we want the good pipefail behaviour https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell - - shell: bash + + - name: Run npm publish + shell: bash run: | cd npm ./publish.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 9c0a008..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: goreleaser - -on: - push: - # run only against tags - tags: - - "*" - -permissions: - contents: write - # packages: write - # issues: write - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - run: git fetch --force --tags - - - uses: actions/setup-go@v4 - with: - go-version: stable - - - uses: goreleaser/goreleaser-action@v4 - with: - # either 'goreleaser' (default) or 'goreleaser-pro': - distribution: goreleaser - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}