Skip to content

Release

Release #24

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Release
on:
push:
tags: [ "*" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
attestations: write
id-token: write
strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Build UI
run: |
sed -i 's#<meta name="version" content="" />#<meta name="version" content="'$GITHUB_REF_NAME'@'$GITHUB_SHA'" />#' index.html
sed -i 's#<span>0.0.0</span>#<span>$GITHUB_REF_NAME</span>#' src/Version.tsx
sed -i 's# "version": "[0-9].[0-9].[0-9]",# "version": "'"$GITHUB_REF_NAME"'",#' package.json
grep version index.html
npm ci
npx tsc --noEmit
npm run build --if-present
tar -czf build.tar.gz dist
- name: Build server
run: |
cd server
sed -i 's# "version": "[0-9].[0-9].[0-9]",# "version": "'"$GITHUB_REF_NAME"'",#' package.json
npm ci
npx tsc --noEmit
- name: Build image
run: |
docker build -t ${GITHUB_REPOSITORY#*/}:${GITHUB_REF_NAME} .
- name: Create SBOMs
run: |
npx --yes @cyclonedx/cyclonedx-npm --output-file swarmview-ui.sbom.json
cd server
npx --yes @cyclonedx/cyclonedx-npm --output-file ../swarmview-server.sbom.json
cd ..
docker run -v /var/run/docker.sock:/var/run/docker.sock -v$(pwd):/app:rw aquasec/trivy --format cyclonedx --output /app/swarmview-docker.sbom.json image ${GITHUB_REPOSITORY#*/}:${GITHUB_REF_NAME}
sed -i 's#"specVersion": "1.6"#"specVersion": "1.5"#' swarmview-docker.sbom.json
docker run -v .:/files cyclonedx/cyclonedx-cli merge --input-files /files/swarmview-docker.sbom.json /files/swarmview-server.sbom.json /files/swarmview-ui.sbom.json --output-file /files/swarmview.sbom.json --group spudsoft --name swarmview --version "$GITHUB_REF_NAME" --hierarchical
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy container image
run: |
echo ${GITHUB_REPOSITORY#*/}
docker image ls | head
IFS=' ' read -ra PARTS <<< `docker image ls | grep ${GITHUB_REPOSITORY#*/} | grep -v ghcr` && \
echo $PARTS
docker tag ${PARTS[2]} ghcr.io/yaytay/${PARTS[0]}:${PARTS[1]} && \
docker push ghcr.io/yaytay/${PARTS[0]}:${PARTS[1]}
docker run --rm -v .:/workspace -v ${HOME}/.docker:/root/.docker -v /var/run/docker:/var/run/docker ghcr.io/oras-project/oras:v1.2.0 attach --artifact-type application/vnd.cyclonedx+json ghcr.io/yaytay/${PARTS[0]}:${PARTS[1]} swarmview.sbom.json
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "swarmview*.sbom.json"
token: ${{ github.token }}
#- name: asciidoctor-ghpages
# uses: manoelcampos/asciidoctor-ghpages-action@v2
# with:
# pdf_build: false
# # asciidoctor_params: --attribute=nofooter
# # adoc_file_ext: .ascii # default is .adoc
# source_dir: docs/
# # slides_build: true
# # pre_build:
# # post_build: