Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,17 @@ jobs:
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@a4f02ab5355a589de60d917a659ce617ed19b3de # v7.3.0
with:
distribution: goreleaser-pro
distribution: goreleaser
version: '~> v2' # latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
GORELEASER_KEY: ${{ secrets.KOSLI_GORELEASERPRO }}

# The build post-hooks in .goreleaser.yml have already copied each
# binary into npm/cli-*/bin.
- name: Pack and publish npm packages
run: bash scripts/npm-publish.sh "${GITHUB_REF_NAME#v}"

- name: Copy npm packages into dist for provenance
run: find npm -name "*.tgz" -exec cp {} dist/ \;
Expand Down
6 changes: 0 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ nfpms:
- src: dist/{{ .ProjectName }}_{{ .Os }}_{{ if .Amd64 }}{{ .Arch }}_v1{{ else if .Arm }}{{ .Arch }}_6{{ else if eq .Arch "arm64" }}{{ .Arch }}_v8.0{{ else }}{{ .Arch }}{{ end }}/kosli
dst: /usr/local/bin/kosli

after:
hooks:
- cmd: bash scripts/npm-publish.sh "{{ .Version }}"{{ if or .IsSnapshot (not .IsRelease) }} --dry-run{{ end }}
# after hooks suppresses output by default. You need to add output: true to the hook to see the script's messages.
output: true

publishers:
- name: fury.io
# by specifying `packages` id here goreleaser will only use this publisher
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ add_test_tag:
build_release: check_dirty add_test_tag
rm -rf dist/
goreleaser release --skip=publish,changelog --verbose
bash scripts/npm-publish.sh 0.0.99 --dry-run
Comment thread
jbrejner marked this conversation as resolved.
Resolved
@git checkout -- npm/ 2> /dev/null || true
Comment thread
jbrejner marked this conversation as resolved.
Resolved
@git tag -d v0.0.99 2> /dev/null || true

clean: ## Clean build artefacts
Expand Down
19 changes: 10 additions & 9 deletions npm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ hooks:
post:
- cmd: >-
bash -c '
OS="{{ .Os }}";
ARCH="{{ .Arch }}";
if [ "$ARCH" = "s390x" ]; then exit 0; fi;
OS="{{ .Os }}";
[ "$OS" = "windows" ] && OS="win32";
[ "$ARCH" = "amd64" ] && ARCH="x64";
EXT="";
Expand All @@ -82,7 +83,7 @@ This hook runs once per build target immediately after goreleaser compiles the b
| `arm64` | `arm64` |
| `arm` | `arm` |

Windows binaries are copied as `kosli.exe`; all others as `kosli`. The `windows/arm` combination is excluded from builds.
Windows binaries are copied as `kosli.exe`; all others as `kosli`. The `windows/arm` combination is excluded from builds, and `s390x` binaries are built but have no npm package.

The `before` hooks in `.goreleaser.yml` clean up stale artifacts before each build run:

Expand Down Expand Up @@ -142,18 +143,18 @@ The dist-tag is determined by the version format:
| `X.Y.Z` | `latest` |
| `X.Y.Z-*` | `snapshot` |

### Integration with GoReleaser
### Integration with the release workflow

GoReleaser calls this script automatically via the `after` hook once all platform binaries have been built and copied into the `bin/` directories:
The `goreleaser` job in [`.github/workflows/release.yml`](../.github/workflows/release.yml) runs this script in a step right after GoReleaser, once all platform binaries have been built and copied into the `bin/` directories:

```yaml
after:
hooks:
- cmd: bash scripts/npm-publish.sh "{{ .Version }}" ...
output: true
- name: Pack and publish npm packages
run: bash scripts/npm-publish.sh "${GITHUB_REF_NAME#v}"
```

The script output is surfaced in the goreleaser log (`output: true`).
The step runs in the same job as GoReleaser, so it inherits the `id-token: write` permission needed for trusted publishing and `--provenance`.

To check the packaging locally without publishing, `make build_release` runs the script with `--dry-run` after a local GoReleaser build.

## Versioning

Expand Down
Loading