Skip to content

Commit 3aea696

Browse files
ci: Use goreleaser-npm-publisher-action v1.6.0 (#104)
Co-authored-by: Matthew Elwell <matthew.elwell@flagsmith.com>
1 parent a5e139c commit 3aea696

2 files changed

Lines changed: 50 additions & 57 deletions

File tree

.github/workflows/release.yml

Lines changed: 49 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ name: Release
33
on:
44
push:
55
tags: ["v*"]
6+
7+
# Dispatch the release workflow for an old tag.
8+
# Useful to backfill previous releases when adding a new publiser,
9+
# or to retry a publisher having fixed a bug in one.
610
workflow_dispatch:
711
inputs:
812
tag:
@@ -12,36 +16,33 @@ on:
1216
permissions:
1317
contents: read
1418

19+
concurrency:
20+
group: release-${{ inputs.tag || github.ref_name }}
21+
1522
jobs:
1623
goreleaser:
1724
runs-on: ubuntu-latest
1825
permissions:
1926
contents: write # upload release artifacts
2027
packages: write # push to ghcr.io
21-
id-token: write # attest artifacts
28+
id-token: write # attest artifacts, npm trusted publishing
2229
attestations: write
2330
steps:
2431
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2532
with:
26-
# Empty on a tag push, where the triggering ref is already the tag.
27-
# Dispatched runs are privileged, so the input can only name a tag,
28-
# never a branch or a pull request.
2933
ref: ${{ inputs.tag && format('refs/tags/{0}', inputs.tag) || '' }}
3034
fetch-depth: 0
3135
persist-credentials: false
3236
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
3337
with:
3438
go-version-file: go.mod
35-
- if: github.event_name == 'push'
36-
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
37-
- if: github.event_name == 'push'
38-
uses: docker/login-action@371161bbe7024a29a25c5e19bfcbc0804fe9ad2c # v4.5.2
39+
- uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
40+
- uses: docker/login-action@371161bbe7024a29a25c5e19bfcbc0804fe9ad2c # v4.5.2
3941
with:
4042
registry: ghcr.io
4143
username: ${{ github.actor }}
4244
password: ${{ secrets.GITHUB_TOKEN }}
4345
- name: Generate GitHub App token
44-
if: github.event_name == 'push'
4546
id: app-token
4647
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
4748
with:
@@ -55,76 +56,67 @@ jobs:
5556
- uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3
5657
with:
5758
version: "~> v2"
58-
# A dispatched run only needs dist/ populated so the npm packages can
59-
# be assembled from it, so it rebuilds the tag's binaries and archives
60-
# nothing. Those binaries won't be byte-identical to the ones already
61-
# released - go.mod asks for Go 1.26, so setup-go resolves whatever
62-
# patch is current - which is why nothing else is republished here.
63-
args: ${{ github.event_name == 'workflow_dispatch' && 'build --clean' || 'release --clean' }}
59+
args: release --clean
6460
env:
6561
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6662
HOMEBREW_TAP_GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
6763
# Attests every file listed in the checksum file.
68-
- if: github.event_name == 'push'
69-
uses: actions/attest@508db95dd578ae2727ebd6217d5ba78e4fbda05d # v4.2.1
64+
- uses: actions/attest@508db95dd578ae2727ebd6217d5ba78e4fbda05d # v4.2.1
7065
with:
7166
subject-checksums: ./dist/checksums.txt
72-
- if: github.event_name == 'push'
73-
uses: actions/attest@508db95dd578ae2727ebd6217d5ba78e4fbda05d # v4.2.1
67+
- uses: actions/attest@508db95dd578ae2727ebd6217d5ba78e4fbda05d # v4.2.1
7468
with:
7569
subject-checksums: ./dist/digests.txt
7670

7771
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
7872
with:
7973
node-version: 24 # npm >= 11.5.1 required for OIDC trusted publishing
80-
# TODO: switch to goreleaser-npm-publisher-action once https://github.com/evg4b/goreleaser-npm-publisher/pull/26 is released
81-
# Prebuilt dist committed on the fork branch
82-
- name: Fetch goreleaser-npm-publisher
83-
run: |
84-
git clone https://github.com/khvn26/goreleaser-npm-publisher "$RUNNER_TEMP/gnp"
85-
git -C "$RUNNER_TEMP/gnp" checkout ad16d393106b23b6289d0569beefb8e9b3bd3159
86-
- name: Install goreleaser-npm-publisher runtime dependencies
87-
working-directory: ${{ runner.temp }}/gnp
88-
# set --mode=skip-build to block third-party install/postinstall scripts
89-
run: corepack yarn install --immutable --mode=skip-build
9074
- name: Publish npm packages
91-
run: >-
92-
node "$RUNNER_TEMP/gnp/dist/cli.cjs" publish
93-
--name cli
94-
--bin flagsmith
95-
--prefix @flagsmith
96-
--license MIT
97-
--repository 'git+https://github.com/Flagsmith/flagsmith-cli.git'
98-
--description 'The Flagsmith command-line interface'
99-
--keywords flagsmith feature-flags cli
100-
--files README.md LICENSE
75+
continue-on-error: ${{ github.event_name == 'workflow_dispatch' }}
76+
uses: evg4b/goreleaser-npm-publisher-action@16087d5aafd974ba267f861cc3723f52ea14d6e4 # v1.6.0
77+
with:
78+
name: cli
79+
bin: flagsmith
80+
prefix: "@flagsmith"
81+
license: MIT
82+
repository: ${{ github.repository }}
83+
description: The Flagsmith command-line interface
84+
keywords: |-
85+
flagsmith
86+
feature-flags
87+
cli
88+
files: |-
89+
README.md
90+
LICENSE
10191
102-
install-script:
103-
name: install.sh (${{ matrix.os }})
92+
install-script-e2e:
93+
name: install (${{ matrix.os }}, ${{ matrix.ref && 'tag' || 'head' }})
10494
needs: goreleaser
105-
if: github.event_name == 'push'
10695
strategy:
10796
fail-fast: false
10897
matrix:
109-
os: [ubuntu-latest, macos-latest]
98+
os: [ubuntu-latest, macos-latest, windows-latest]
99+
# When release is dispatched, test both pinned and latest installers.
100+
# For a normal (tag-pushed) release, test only latest installer.
101+
ref: ${{ fromJSON(inputs.tag && format('["", "refs/tags/{0}"]', inputs.tag) || '[""]') }}
110102
runs-on: ${{ matrix.os }}
111103
steps:
112104
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
113105
with:
106+
ref: ${{ matrix.ref }}
114107
persist-credentials: false
115-
- run: sh install.sh --version "$GITHUB_REF_NAME" --bin-dir "$RUNNER_TEMP/bin"
116-
- run: flagsmith --version
117-
118-
install-script-windows:
119-
name: install.ps1
120-
needs: goreleaser
121-
if: github.event_name == 'push'
122-
runs-on: windows-latest
123-
steps:
124-
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
125-
with:
126-
persist-credentials: false
127-
- run: ./install.ps1 -Version $env:GITHUB_REF_NAME
108+
- name: Install latest (Linux)
109+
if: ${{ !inputs.tag && runner.os != 'Windows' }}
110+
run: sh install.sh
111+
- name: Install dispatched (Linux)
112+
if: ${{ inputs.tag && runner.os != 'Windows' }}
113+
run: sh install.sh --version "${{ inputs.tag }}"
114+
- name: Install latest (Windows)
115+
if: ${{ !inputs.tag && runner.os == 'Windows' }}
116+
run: ./install.ps1
128117
shell: pwsh
129-
- run: flagsmith --version
118+
- name: Install dispatched (Windows)
119+
if: ${{ inputs.tag && runner.os == 'Windows' }}
120+
run: ./install.ps1 -Version "${{ inputs.tag }}"
130121
shell: pwsh
122+
- run: flagsmith --version

.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,4 @@ changelog:
8989
release:
9090
mode: keep-existing
9191
prerelease: auto
92+
replace_existing_artifacts: true

0 commit comments

Comments
 (0)