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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Keeps the actions pinned by commit SHA in .github/workflows up to date.
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
18 changes: 11 additions & 7 deletions .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ jobs:
if: "!contains(github.event.commits[0].message, 'Release')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: setup-node
uses: actions/setup-node@v2.5.1
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 18
package-manager-cache: false
registry-url: https://registry.npmjs.org/
- id: build-and-analyse
- id: install
run: npm ci --ignore-scripts
- id: test
env:
CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
Expand All @@ -34,7 +39,6 @@ jobs:
CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET }}
CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID }}
CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET }}
run: |
npm ci --ignore-scripts
npm test
npm run build
run: npm test
- id: build
run: npm run build
18 changes: 11 additions & 7 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: setup-node
uses: actions/setup-node@v2.5.1
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 18
package-manager-cache: false
registry-url: https://registry.npmjs.org/
- id: build-and-analyse
- id: install
run: npm ci --ignore-scripts
- id: test
env:
CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
Expand All @@ -33,8 +38,7 @@ jobs:
CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET }}
CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID }}
CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET }}
run: |
npm ci --ignore-scripts
npm test
npm run build
run: npm test
- id: build
run: npm run build

176 changes: 146 additions & 30 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ on:
paths:
- package.json

permissions:
contents: read

# One release at a time; a second run waits instead of starting in parallel.
concurrency:
group: build-release
cancel-in-progress: false

jobs:
deploy:
# Unit and integration tests; the only job with the integration test secrets.
test:
runs-on: ubuntu-latest
# Must match the environment configured on the npm trusted publisher
environment: production
permissions:
contents: write # create the GitHub release
id-token: write # npm trusted publishing (OIDC)
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- id: setup-node
uses: actions/setup-node@v4
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
registry-url: https://registry.npmjs.org/
- id: upgrade-npm
# Trusted publishing needs npm >= 11.5.1; Node 22 bundles npm 10.
# Pinned so the release job is reproducible.
run: npm install -g npm@11.21.0 --ignore-scripts && npm --version
- id: build-and-analyse
package-manager-cache: false
- id: install
run: npm ci --ignore-scripts
- id: test
env:
CHECKOUT_PROCESSING_CHANNEL_ID: ${{ secrets.IT_CHECKOUT_PROCESSING_CHANNEL_ID }}
CHECKOUT_PREVIOUS_SECRET_KEY: ${{ secrets.IT_CHECKOUT_PREVIOUS_SECRET_KEY }}
Expand All @@ -41,27 +45,139 @@ jobs:
CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ACCOUNTS_CLIENT_SECRET }}
CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_ID }}
CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET: ${{ secrets.IT_CHECKOUT_DEFAULT_OAUTH_ISSUING_CLIENT_SECRET }}
run: npm test

# Builds and packs the package after the tests pass; no secrets.
build:
needs: test
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
tarball: ${{ steps.pack.outputs.tarball }}
sha256: ${{ steps.pack.outputs.sha256 }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Read before the install, as checked out.
- id: version
run: |
npm ci
npm test
npm run build
set -euo pipefail
version=$(jq -r .version package.json)
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::package.json version is not a release version (x.y.z)"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- id: setup-node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
package-manager-cache: false
- id: install
run: npm ci --ignore-scripts
- id: build
run: npm run build
- id: rsync
run: rsync -avh --progress ./types/ ./
- id: read-version
run: echo "CURRENT_VERSION=$( awk -F'"' '/version/ {print $4}' package.json )" >> $GITHUB_ENV
- id: print-version
run: echo "Releasing $CURRENT_VERSION"
- id: pack
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
version="$VERSION"
mkdir -p "$RUNNER_TEMP/package"
npm pack --ignore-scripts --pack-destination "$RUNNER_TEMP/package"
tarball="checkout-sdk-node-$version.tgz"
test -f "$RUNNER_TEMP/package/$tarball" || { echo "::error::npm pack did not produce $tarball"; exit 1; }
sha256=$(sha256sum "$RUNNER_TEMP/package/$tarball" | cut -d' ' -f1)
{
echo "tarball=$tarball"
echo "sha256=$sha256"
} >> "$GITHUB_OUTPUT"
echo "Releasing $version ($tarball, sha256 $sha256)"
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: package
path: ${{ runner.temp }}/package/${{ steps.pack.outputs.tarball }}
if-no-files-found: error
retention-days: 7

# Publishes the tarball built above.
publish:
needs: build
runs-on: ubuntu-latest
# Must match the environment configured on the npm trusted publisher
environment: production
permissions:
id-token: write # npm trusted publishing (OIDC)
steps:
- id: setup-node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
package-manager-cache: false
registry-url: https://registry.npmjs.org/
- id: upgrade-npm
# Trusted publishing needs npm >= 11.5.1; Node 22 bundles npm 10.
# Pinned by version and by the registry's sha512 integrity of that version.
env:
NPM_INTEGRITY: sha512-Zov8KhamNneiLdELtj5YALtNmJW4L4fCLTzjfpzXG2w6MSHcf0UxgdlK5uloCuksWT+7mGUU7wi79cO6RqivPg==
run: |
set -euo pipefail
cd "$(mktemp -d)"
curl -fsSL --proto '=https' -o npm-11.21.0.tgz https://registry.npmjs.org/npm/-/npm-11.21.0.tgz
test "sha512-$(openssl dgst -sha512 -binary npm-11.21.0.tgz | base64 -w0)" = "$NPM_INTEGRITY" \
|| { echo "::error::npm 11.21.0 download does not match its integrity"; exit 1; }
npm install -g ./npm-11.21.0.tgz --ignore-scripts
npm --version
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: package
path: ${{ runner.temp }}/package
- id: verify
env:
VERSION: ${{ needs.build.outputs.version }}
TARBALL: ${{ needs.build.outputs.tarball }}
SHA256: ${{ needs.build.outputs.sha256 }}
run: |
set -euo pipefail
fail() { echo "::error::Package check failed: $1"; exit 1; }
cd "$RUNNER_TEMP/package"
[ "$TARBALL" = "checkout-sdk-node-$VERSION.tgz" ] || fail "file name"
[ "$(find . -type f | wc -l)" -eq 1 ] || fail "file count"
echo "$SHA256 $TARBALL" | sha256sum -c - || fail "sha256"
# Every entry a regular file under package/ with a plain path, one manifest.
tar --ignore-zeros -tzf "$TARBALL" > "$RUNNER_TEMP/entries" 2> "$RUNNER_TEMP/tar-errors" || fail "archive"
tar --ignore-zeros -tvzf "$TARBALL" > "$RUNNER_TEMP/entries-long" 2>> "$RUNNER_TEMP/tar-errors" || fail "archive"
[ ! -s "$RUNNER_TEMP/tar-errors" ] || fail "archive warnings"
# Counts read from the files, no pipe: anything but 0 (an error included) refuses.
[ "$(grep -c -v -E '^package/[^/]' "$RUNNER_TEMP/entries" || true)" = 0 ] || fail "entry outside package/"
[ "$(grep -c -E '(^|/)\.{1,2}(/|$)|//' "$RUNNER_TEMP/entries" || true)" = 0 ] || fail "entry path"
[ "$(grep -c -v '^-' "$RUNNER_TEMP/entries-long" || true)" = 0 ] || fail "entry type"
[ "$(grep -c -x 'package/package.json' "$RUNNER_TEMP/entries")" -eq 1 ] || fail "manifest count"
tar --ignore-zeros -xzOf "$TARBALL" package/package.json | jq -e 'has("publishConfig") | not' > /dev/null || fail "publishConfig"
# Name, version, registry and tag as npm reads the file.
npm publish "$TARBALL" --dry-run --json --access public > "$RUNNER_TEMP/dry-run.json" 2> "$RUNNER_TEMP/dry-run.log" || fail "npm dry run"
[ "$(jq -r 'keys | join(",")' "$RUNNER_TEMP/dry-run.json")" = "checkout-sdk-node" ] || fail "package name"
[ "$(jq -r '.["checkout-sdk-node"].id' "$RUNNER_TEMP/dry-run.json")" = "checkout-sdk-node@$VERSION" ] || fail "package version"
grep -q -x 'npm notice Publishing to https://registry.npmjs.org/ with tag latest and public access (dry-run)' "$RUNNER_TEMP/dry-run.log" || fail "registry or tag"
- id: publish-to-npm
# No token: npm exchanges the GitHub OIDC token with the registry
# and publishes with provenance.
run: npm publish --provenance --access public
env:
VERSION: ${{ needs.build.outputs.version }}
run: npm publish "$RUNNER_TEMP/package/checkout-sdk-node-$VERSION.tgz" --provenance --access public

github-release:
needs: [build, publish]
runs-on: ubuntu-latest
permissions:
contents: write # create the GitHub release
steps:
- id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.CURRENT_VERSION }}
release_name: ${{ env.CURRENT_VERSION }}
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.build.outputs.version }}
NOTES: ${{ github.event.head_commit.message }}
run: gh release create "$VERSION" --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" --title "$VERSION" --notes "$NOTES"
62 changes: 0 additions & 62 deletions .github/workflows/codeql-analysis.yml

This file was deleted.