Skip to content

Update README

Update README #8

Workflow file for this run

name: Publish compass-web to NPM and Docker Hub
on:
workflow_dispatch:
push:
tags:
- 'v*'
jobs:
publish-npm:
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check-version.outputs.version }}
is_latest: ${{ steps.check-version.outputs.is_latest }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- name: Check version
id: check-version
run: |
version=$(node -e "console.log(require('./package.json').version);")
if [[ "${{ github.event_name }}" == "push" ]]; then
if [[ "${GITHUB_REF##*/v}" != "$version" ]]; then
echo "Tag and npm version don't match"
exit 1
fi
fi
echo "version=${version}" >> $GITHUB_OUTPUT
if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "is_latest=true"
echo "is_latest=true" >> $GITHUB_OUTPUT
else
echo "is_latest=false"
echo "is_latest=false" >> $GITHUB_OUTPUT
fi
- run: npm ci
- name: Build compass-web
run: |
NODE_ENV=production npm run build
NODE_ENV=production npm run build-server
- name: Publish compass-web
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
version=${{ steps.check-version.outputs.version }}
if [[ "$version" == *alpha* ]]; then
tag='--tag alpha'
elif [[ "$version" == *beta* ]]; then
tag='--tag beta'
elif [[ "$TAG" == *rc* ]]; then
tag='--tag rc'
else
tag=''
fi
npm publish ${tag} --provenance --access public
publish-docker:
needs:
- publish-npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: haohanyang
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: haohanyang/compass-web:${{ needs.publish-npm.outputs.version }}
provenance: mode=max
platforms: linux/amd64,linux/arm64
build-args: COMPASS_WEB_VERSION=${{ needs.publish-npm.outputs.version }}
- name: Build and push
uses: docker/build-push-action@v6
if: ${{ needs.publish-npm.outputs.is_latest != 'true' }}
with:
push: true
tags: haohanyang/compass-web:${{ needs.publish-npm.outputs.version }}
provenance: mode=max
platforms: linux/amd64,linux/arm64
build-args: COMPASS_WEB_VERSION=${{ needs.publish-npm.outputs.version }}
- name: Build and push with latest tag
uses: docker/build-push-action@v6
if: ${{ needs.publish-npm.outputs.is_latest == 'true' }}
with:
push: true
tags: haohanyang/compass-web:${{ needs.publish-npm.outputs.version }},haohanyang/compass-web:latest
provenance: mode=max
platforms: linux/amd64,linux/arm64
build-args: COMPASS_WEB_VERSION=${{ needs.publish-npm.outputs.version }}