Skip to content

Release

Release #103

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
version_type:
description: 'Version type (major, minor, patch)'
required: false
default: 'patch'
type: choice
options:
- major
- minor
- patch
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.bump-version.outputs.version }}
steps:
- name: Fail if branch is not main
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'
run: |
echo "This workflow should not be triggered with workflow_dispatch on a branch other than main"
exit 1
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: true
- name: Check commit author
id: author-check
run: |
AUTHOR_EMAIL=$(git log -1 --pretty=format:'%ae')
echo "author_email=$AUTHOR_EMAIL" >> $GITHUB_OUTPUT
- name: Skip if commit is from GitHub Actions
if: steps.author-check.outputs.author_email == '[email protected]'
run: |
echo "Commit from GitHub Actions — skipping release"
exit 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm
- name: Install dependencies
run: npm ci
- name: Configure Git user
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
- name: Bump and tag version
id: bump-version
run: |
PREV_VERSION=$(node -p "require('./package.json').version")
echo "PREV_VERSION=$PREV_VERSION" >> $GITHUB_ENV
VERSION_TYPE="${{ github.event.inputs.version_type || 'patch' }}"
npm version $VERSION_TYPE --message "release:%s"
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Test
run: |
if [ -f "package.json" ] && grep -q '"test"' package.json; then
npm test
else
echo "No test script defined, skipping tests."
fi
- name: Build
run: npm run build:prod
- name: Push commit and tag
run: git push origin main --follow-tags
- name: Zip build output
run: |
cd dist
ZIP_NAME="index.html-${{ env.VERSION }}.zip"
zip -r "../$ZIP_NAME" .
cd ..
echo "ZIP_NAME=$ZIP_NAME" >> $GITHUB_ENV
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: index-html-${{ env.VERSION }}-zip
path: ${{ env.ZIP_NAME }}
- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
mode: 'PR'
ignorePreReleases: 'false'
fromTag: 'v${{ env.PREV_VERSION }}'
toTag: 'v${{ env.VERSION }}'
configurationJson: |
{
"template": "## Release Notes\n\n#{{CHANGELOG}}",
"categories": [
{
"title": "### 🚀 Enhancements",
"labels": ["feat", "feature"]
},
{
"title": "### 🛠 Fixes",
"labels": ["fix", "bug"]
},
{
"title": "### 🛡️ Security",
"labels": ["security"]
},
{
"title": "### ⚡️ Performance",
"labels": ["perf"]
},
{
"title": "### 🎨 Styling",
"labels": ["style"]
},
{
"title": "### 🧪 Testing",
"labels": ["test"]
},
{
"title": "### 📚 Documentation",
"labels": ["docs"]
},
{
"title": "### ◀️ Revert",
"labels": ["revert"]
},
{
"title": "### 💼 Other",
"labels": []
}
],
"ignore_labels": [
"ignore",
"build",
"chore",
"ci",
"refactor",
"review",
"release"
],
"label_extractor": [
{
"pattern": "^([a-z]+)?:?\\s*(.*)",
"on_property": "title",
"target": "$1"
}
],
"commitIgnorePatterns": [
"^release:\\d+\\.\\d+\\.\\d+$",
"^\\d+\\.\\d+\\.\\d+$"
]
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.VERSION }}
name: v${{ env.VERSION }}
body: ${{steps.build_changelog.outputs.changelog}}
files: ${{ env.ZIP_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
runs-on: ubuntu-latest
needs: release
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout specific tag
uses: actions/checkout@v4
with:
ref: v${{ needs.release.outputs.version }}
- name: Use the version
run: echo "Deploying version ${{ needs.release.outputs.version }}"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Set basePath variable
id: vars
run: echo "basePath=${{ github.event.repository.name }}" >> $GITHUB_ENV
- name: Build
run: npm run build:prod
- name: Set custom domain
run: echo "llama-ui.js.org" >> ./dist/CNAME
- name: Deploy
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
docker:
runs-on: ubuntu-latest
needs: release
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout specific tag
uses: actions/checkout@v4
with:
ref: v${{ needs.release.outputs.version }}
- name: Use the version
run: echo "Building Docker image for version ${{ needs.release.outputs.version }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
file: .devops/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}