diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a7af4f5bc..9ad5b1f98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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/ \; diff --git a/.goreleaser.yml b/.goreleaser.yml index 9f3663fec..cef39b014 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -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 diff --git a/Makefile b/Makefile index 7329c6c77..751f0d2c1 100644 --- a/Makefile +++ b/Makefile @@ -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 + @git checkout -- npm/ 2> /dev/null || true @git tag -d v0.0.99 2> /dev/null || true clean: ## Clean build artefacts diff --git a/npm/README.md b/npm/README.md index 54dbbe8d1..c26796cae 100644 --- a/npm/README.md +++ b/npm/README.md @@ -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=""; @@ -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: @@ -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