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
41 changes: 34 additions & 7 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: publish

permissions:
id-token: write # required for OIDC
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -9,17 +13,40 @@ on:
tags:
- 'v*'

env:
NODE_VERSION: "24" # at least Node 24 is required for Trusted Publishing with OIDC

jobs:
publish:
runs-on: ubuntu-latest
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
name: Checkout
uses: actions/checkout@v6
-
name: Publish
uses: docker/bake-action@v6
name: Enable corepack
run: |
corepack enable
yarn --version
-
name: Setup Node
uses: actions/setup-node@v6
with:
targets: publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
node-version: ${{ env.NODE_VERSION }}
cache: 'yarn'
-
name: Print versions
run: |
node --version
npm --version
yarn --version
-
name: Build
run: |
yarn install
yarn run build
-
name: Publish
run: |
npm version --no-git-tag-version ${GITHUB_REF#refs/tags/v}
npm publish --provenance --access public
21 changes: 0 additions & 21 deletions dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,3 @@ RUN --mount=type=bind,target=.,rw \

FROM scratch AS test-coverage
COPY --from=test /tmp/coverage /

FROM base AS publish
ARG GITHUB_REF
RUN --mount=type=bind,target=.,rw \
--mount=type=cache,target=/src/.yarn/cache \
--mount=type=cache,target=/src/node_modules \
--mount=type=secret,id=NODE_AUTH_TOKEN,env=NODE_AUTH_TOKEN <<EOT
set -e
if ! [[ $GITHUB_REF =~ ^refs/tags/v ]]; then
echo "GITHUB_REF is not a tag"
exit 1
fi
yarn install
yarn run build
npm config set //registry.npmjs.org/:_authToken $NODE_AUTH_TOKEN
npm version --no-git-tag-version ${GITHUB_REF#refs/tags/v}
npm publish --access public

# FIXME: Can't publish with yarn berry atm: https://github.com/changesets/changesets/pull/674
#yarn publish --no-git-tag-version --new-version ${GITHUB_REF#refs/tags/v}
EOT
17 changes: 0 additions & 17 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,6 @@ target "test-coverage" {
secret = ["id=GITHUB_TOKEN,env=GITHUB_TOKEN"]
}

# GITHUB_REF is the actual ref that triggers the workflow and used as version
# when a tag is pushed: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
variable "GITHUB_REF" {
default = ""
}

target "publish" {
inherits = ["_common"]
dockerfile = "dev.Dockerfile"
args = {
GITHUB_REF = GITHUB_REF
}
target = "publish"
output = ["type=cacheonly"]
secret = ["id=NODE_AUTH_TOKEN,env=NODE_AUTH_TOKEN"]
}

target "license-validate" {
inherits = ["_common"]
dockerfile = "./hack/dockerfiles/license.Dockerfile"
Expand Down
Loading