Merge pull request #167 from juicyllama/refactor/auth-and-role-refact… #143
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
# | |
# GitHub Actions workflow. | |
# | |
# Releases the package to npm when a push into main is detected. | |
# * Checkout the code | |
# * Install Node.js | |
# * Install dependencies | |
# * Pull the latest changes | |
# * Bump version number | |
# * Release to NPM | |
# * Pull the latest changes | |
# * Generate Docker meta | |
# * Build and push image | |
# | |
name: 'Release Package: Llana' | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
release: | |
name: 'Release Package: CLI' | |
runs-on: ubuntu-latest | |
if: ${{ !contains(github.event.head_commit.message, '#skip-release') }} | |
permissions: | |
contents: write | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_CI_CD_RELEASE }} | |
- name: 'Install Node.js' | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.18.2 | |
- name: 'Install dependencies' | |
run: npm install | |
- run: git pull --force | |
- name: 'Version Bump' | |
id: version | |
if: ${{ !contains(github.event.head_commit.message, '#skip-version-bump') }} | |
uses: phips28/gh-action-bump-version@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_CI_CD_RELEASE }} | |
with: | |
major-wording: 'MAJOR' | |
minor-wording: 'feature,feat' | |
patch-wording: 'patch,fixes,fix,misc,docs,refactor' # Providing patch-wording will override commits | |
commit-message: 'CI: Bump Version to {{version}} [skip ci]' | |
tag-prefix: 'v' | |
- run: git pull --force #Ensure we have the latest package version before pushing to NPM / Docker | |
- name: 'Authenticate with NPM' | |
if: ${{ !contains(github.event.head_commit.message, '#skip-npm-publish') }} | |
run: echo -e "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc | |
- name: 'Publishing package' | |
if: ${{ !contains(github.event.head_commit.message, '#skip-npm-publish') }} | |
run: npm publish --no-git-checks --access public | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
juicyllama/llana | |
# ghcr.io/username/app | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=semver,pattern=v{{version}},value=${{ steps.version.outputs.newTag }} | |
type=semver,pattern=v{{major}}.{{minor}},value=${{ steps.version.outputs.newTag }} | |
type=semver,pattern=v{{major}},value=${{ steps.version.outputs.newTag }} | |
type=sha | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: juicyllama | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
#Checkout again to get latest package.json after bump and before we deploy | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_CI_CD_RELEASE }} | |
- name: Build and push image | |
uses: docker/build-push-action@v6 | |
if: ${{ !contains(github.event.head_commit.message, '#skip-docker-publish') }} | |
with: | |
file: ./docker/images/base/Dockerfile | |
sbom: true | |
provenance: mode=max | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 |