Release npm package and container image #495
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release npm package and container image | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
jobs: | |
pkg: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
registry-url: https://registry.npmjs.org/ | |
- name: Trim CI agent | |
run: | | |
chmod +x contrib/free_disk_space.sh | |
./contrib/free_disk_space.sh | |
- name: Release npm package | |
if: startsWith(github.ref, 'refs/tags/') | |
run: | | |
npm config set //npm.pkg.github.com/:_authToken=$GITHUB_TOKEN | |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN | |
echo "cyclonedx:registry=https://npm.pkg.github.com" > ~/.npmrc | |
npm publish --access=public --@cyclonedx:registry='https://npm.pkg.github.com' | |
echo "cyclonedx:registry=https://registry.npmjs.org" > ~/.npmrc | |
npm publish --provenance --access=public --@cyclonedx:registry='https://registry.npmjs.org' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
containers: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
registry-url: https://registry.npmjs.org/ | |
- name: Trim CI agent | |
run: | | |
chmod +x contrib/free_disk_space.sh | |
./contrib/free_disk_space.sh | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/cyclonedx/cdxgen | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ci/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=gha,scope=cdxgen | |
cache-to: type=gha,mode=max,scope=cdxgen | |
- name: Attach cdx sbom | |
run: | | |
npm install | |
node bin/cdxgen.js --generate-key-and-sign -t docker -o bom.json --deep ghcr.io/cyclonedx/cdxgen | |
oras attach --artifact-type sbom/cyclonedx --image-spec v1.1-artifact ghcr.io/cyclonedx/cdxgen:${{ steps.meta.outputs.tags }} ./bom.json:application/json | |
oras discover -o tree ghcr.io/cyclonedx/cdxgen:${{ steps.meta.outputs.tags }} | |
env: | |
CDXGEN_DEBUG_MODE: debug | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta2 | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/cyclonedx/cdxgen-deno | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ci/Dockerfile-deno | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta2.outputs.tags }} | |
labels: ${{ steps.meta2.outputs.labels }} | |
cache-from: type=gha,scope=cdxgen-deno | |
cache-to: type=gha,mode=max,scope=cdxgen-deno | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta3 | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/cyclonedx/cdxgen-ppc64 | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ci/Dockerfile-ppc64 | |
platforms: linux/ppc64le | |
push: true | |
tags: ${{ steps.meta3.outputs.tags }} | |
labels: ${{ steps.meta3.outputs.labels }} | |
cache-from: type=gha,scope=cdxgen-ppc64 | |
cache-to: type=gha,mode=max,scope=cdxgen-ppc64 | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta4 | |
uses: docker/metadata-action@v4 | |
with: | |
images: | | |
ghcr.io/cyclonedx/cdxgen-next | |
if: github.ref == 'refs/heads/master' | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: ci/Dockerfile-fedora | |
platforms: linux/amd64 | |
push: true | |
tags: ${{ steps.meta4.outputs.tags }} | |
labels: ${{ steps.meta4.outputs.labels }} | |
cache-from: type=gha,scope=cdxgen-next | |
cache-to: type=gha,mode=max,scope=cdxgen-next | |
if: github.ref == 'refs/heads/master' |