Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 74 additions & 8 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ name: Build and Push Multi-Arch Image
on:
workflow_dispatch:
push:
branches: [ main, dev ]
branches: [ main, dev, qbit-session ]
tags:
- 'v*'
pull_request:
branches: [ main, dev ]
branches: [ main, dev, qbit-session ]

env:
REGISTRY: ghcr.io
Expand All @@ -16,11 +18,67 @@ jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
packages: write
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Node.js
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm

- name: Install release tooling
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
run: npm ci

- name: Preview next semantic release
id: release_preview
if: github.event_name == 'push' && github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
output="$(npx semantic-release --dry-run --no-ci 2>&1 || true)"
printf '%s\n' "$output"

if printf '%s\n' "$output" | grep -q "There are no relevant changes, so no new version is released."; then
echo "release_needed=false" >> "$GITHUB_OUTPUT"
exit 0
fi

version="$(printf '%s\n' "$output" | sed -nE 's/.*The next release version is ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p' | tail -n 1)"

if [ -z "$version" ]; then
echo "Unable to determine the next release version from semantic-release output." >&2
exit 1
fi

echo "release_needed=true" >> "$GITHUB_OUTPUT"
echo "version=$version" >> "$GITHUB_OUTPUT"

- name: Prepare automated release tags
id: release_tags
if: steps.release_preview.outputs.release_needed == 'true'
run: |
version="${{ steps.release_preview.outputs.version }}"
major="${version%%.*}"
minor="${version#*.}"
minor="${minor%%.*}"

{
echo "tags<<EOF"
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${version}"
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${major}.${minor}"
echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${major}"
echo "EOF"
} >> "$GITHUB_OUTPUT"

- name: Set up QEMU
uses: docker/setup-qemu-action@v4
Expand All @@ -44,22 +102,30 @@ jobs:
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
type=sha,format=short
type=raw,value=qbit-session,enable=${{ github.ref == 'refs/heads/qbit-session' }}
type=sha,format=short,enable=${{ startsWith(github.ref, 'refs/heads/') }}
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}

- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ env.PLATFORMS }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
tags: |
${{ steps.meta.outputs.tags }}
${{ steps.release_tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GIT_COMMIT=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Create semantic release
if: steps.release_preview.outputs.release_needed == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
15 changes: 4 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@ on:

jobs:
release:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@v4.7.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.changelog }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ venv/
*au*
.env
.venv
node_modules/
dist/
build/
*.egg-info/
Expand All @@ -20,4 +21,5 @@ coverage.xml
.LSOverride
._*
.vscode/
tmp/
tmp/
notes.md
43 changes: 43 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"branches": [
"main"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "perf",
"release": "patch"
},
{
"type": "chore",
"scope": "deps",
"release": "patch"
},
{
"type": "docs",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/github"
]
}
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ services:
interval: 30s
timeout: 10s
retries: 3
restart: always
restart: always
Loading