Skip to content

Commit fcfc1fa

Browse files
committed
feat: release workflow [skip ci]
fix: add config file for changelog builder fix: compare to newest branch fix: use hybrid mode fix: refine changelog config fix: number not showing up fix: commit numbers fix: link markdown fix: long sha links fix: clean up changelog fix: failing release fix: too aggressive sed fix: regex stuff fix: remove the sha
1 parent e0175b2 commit fcfc1fa

File tree

3 files changed

+146
-71
lines changed

3 files changed

+146
-71
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"categories": [
3+
{
4+
"title": "## 📝 What's Changed",
5+
"labels": []
6+
}
7+
],
8+
"template": "${{CHANGELOG}}\n\n## 👥 Contributors\n${{CONTRIBUTORS}}",
9+
"pr_template": "* ${{TITLE}} by @${{AUTHOR}} in #${{NUMBER}}",
10+
"commit_template": "* ${{TITLE}} by @${{AUTHOR}}",
11+
"empty_template": "* no changes",
12+
"fetch_release_information": true
13+
}

.github/workflows/docker-publish.yml

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -3,85 +3,84 @@ name: Docker
33
# Based on a template from GitHub
44

55
on:
6-
push:
7-
branches: [ "main", "develop", "nightly" ]
8-
# Publish semver tags as releases.
9-
tags: [ 'v*.*.*' ]
10-
pull_request:
11-
branches: [ "main", "develop", "nightly" ]
6+
push:
7+
branches: ["main", "develop", "nightly"]
8+
# Publish semver tags as releases.
9+
tags: ["v*.*.*"]
10+
pull_request:
11+
branches: ["main", "develop", "nightly"]
1212

1313
env:
14-
# Use docker.io for Docker Hub if empty
15-
REGISTRY: ghcr.io
16-
# github.repository as <account>/<repo>
17-
IMAGE_NAME: ${{ github.repository }}
14+
# Use docker.io for Docker Hub if empty
15+
REGISTRY: ghcr.io
16+
# github.repository as <account>/<repo>
17+
IMAGE_NAME: ${{ github.repository }}
1818

1919
jobs:
20-
build:
20+
build:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
# This is used to complete the identity challenge
26+
# with sigstore/fulcio when running outside of PRs.
27+
id-token: write
2128

22-
runs-on: ubuntu-latest
23-
permissions:
24-
contents: read
25-
packages: write
26-
# This is used to complete the identity challenge
27-
# with sigstore/fulcio when running outside of PRs.
28-
id-token: write
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v6
32+
with:
33+
# we need the whole thing so we can count commits.
34+
fetch-depth: "0"
2935

30-
steps:
31-
- name: Checkout repository
32-
uses: actions/checkout@v6
33-
with:
34-
# we need the whole thing so we can count commits.
35-
fetch-depth: '0'
36+
- name: Set up QEMU
37+
uses: docker/setup-qemu-action@v3
38+
with:
39+
platforms: "arm64"
3640

37-
- name: Set up QEMU
38-
uses: docker/setup-qemu-action@v3
39-
with:
40-
platforms: 'arm64'
41+
# Workaround: https://github.com/docker/build-push-action/issues/461
42+
- name: Setup Docker buildx
43+
uses: docker/setup-buildx-action@v3
4144

42-
# Workaround: https://github.com/docker/build-push-action/issues/461
43-
- name: Setup Docker buildx
44-
uses: docker/setup-buildx-action@v3
45+
# Login against a Docker registry except on PR
46+
# https://github.com/docker/login-action
47+
- name: Log into registry ${{ env.REGISTRY }}
48+
if: github.event_name != 'pull_request'
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ${{ env.REGISTRY }}
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
4554

46-
# Login against a Docker registry except on PR
47-
# https://github.com/docker/login-action
48-
- name: Log into registry ${{ env.REGISTRY }}
49-
if: github.event_name != 'pull_request'
50-
uses: docker/login-action@v3
51-
with:
52-
registry: ${{ env.REGISTRY }}
53-
username: ${{ github.actor }}
54-
password: ${{ secrets.GITHUB_TOKEN }}
55+
# Extract metadata (tags, labels) for Docker
56+
# https://github.com/docker/metadata-action
57+
- name: Extract Docker metadata
58+
id: meta
59+
uses: docker/metadata-action@v5
60+
with:
61+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5562

56-
# Extract metadata (tags, labels) for Docker
57-
# https://github.com/docker/metadata-action
58-
- name: Extract Docker metadata
59-
id: meta
60-
uses: docker/metadata-action@v5
61-
with:
62-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
63+
- name: More Docker metadata
64+
run: |
65+
echo BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:00Z) >> $GITHUB_ENV
66+
echo COMMITS=$(git rev-list --count --all || echo 0) >> $GITHUB_ENV
6367
64-
- name: More Docker metadata
65-
run: |
66-
echo BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:00Z) >> $GITHUB_ENV
67-
echo COMMITS=$(git rev-list --count --all || echo 0) >> $GITHUB_ENV
68-
69-
# Build and push Docker image with Buildx (don't push on PR)
70-
# https://github.com/docker/build-push-action
71-
- name: Build and push Docker image
72-
id: build-and-push
73-
uses: docker/build-push-action@v6
74-
with:
75-
context: .
76-
file: docker/Dockerfile
77-
platforms: linux/amd64,linux/arm64
78-
push: ${{ github.event_name != 'pull_request' }}
79-
tags: ${{ steps.meta.outputs.tags }}
80-
labels: ${{ steps.meta.outputs.labels }}
81-
cache-from: type=gha
82-
cache-to: type=gha,mode=max
83-
build-args: |
84-
"BUILD_DATE=${{ env.BUILD_DATE }}"
85-
"COMMITS=${{ env.COMMITS }}"
86-
"BRANCH=${{ github.ref_name }}"
87-
"COMMIT=${{ github.sha }}"
68+
# Build and push Docker image with Buildx (don't push on PR)
69+
# https://github.com/docker/build-push-action
70+
- name: Build and push Docker image
71+
id: build-and-push
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: .
75+
file: docker/Dockerfile
76+
platforms: linux/amd64,linux/arm64
77+
push: ${{ github.event_name != 'pull_request' }}
78+
tags: ${{ steps.meta.outputs.tags }}
79+
labels: ${{ steps.meta.outputs.labels }}
80+
cache-from: type=gha
81+
cache-to: type=gha,mode=max
82+
build-args: |
83+
"BUILD_DATE=${{ env.BUILD_DATE }}"
84+
"COMMITS=${{ env.COMMITS }}"
85+
"BRANCH=${{ github.ref_name }}"
86+
"COMMIT=${{ github.sha }}"

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
major_minor:
7+
description: "Major/Minor version"
8+
required: true
9+
default: "0.6"
10+
11+
jobs:
12+
build-release:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v6
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Calculate Version String
24+
run: |
25+
COMMITS=$(git rev-list --count --all || echo 0)
26+
VERSION=v${{ github.event.inputs.major_minor }}.${COMMITS}
27+
echo RELEASE_TAG=${VERSION} >> $GITHUB_ENV
28+
29+
- name: Generate Changelog
30+
id: build_changelog
31+
uses: mikepenz/release-changelog-builder-action@v6
32+
with:
33+
configuration: ".github/release-changelog-config.json"
34+
toTag: ${{ github.ref_name }}
35+
mode: "HYBRID"
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
39+
- name: Clean up changelog
40+
id: process_log
41+
run: |
42+
echo "${{ steps.build_changelog.outputs.changelog }}" > changelog.md
43+
44+
# Add a full changelog link at the bottom of changelog
45+
COMPARE_LINK="**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.build_changelog.outputs.fromTag }}...${{ env.RELEASE_TAG }}"
46+
47+
# Combine output
48+
echo "final_body<<EOF" >> $GITHUB_OUTPUT
49+
cat changelog.md >> $GITHUB_OUTPUT
50+
echo -e "\n" >> $GITHUB_OUTPUT
51+
echo "$COMPARE_LINK" >> $GITHUB_OUTPUT
52+
echo "EOF" >> $GITHUB_OUTPUT
53+
54+
- name: Create Release
55+
uses: softprops/action-gh-release@v2
56+
with:
57+
tag_name: ${{ env.RELEASE_TAG }}
58+
name: ${{ env.RELEASE_TAG }}
59+
body: ${{ steps.process_log.outputs.final_body }}
60+
prerelease: ${{ github.ref_name != 'main' }}
61+
make_latest: ${{ github.ref_name == 'main' && 'true' || 'false' }}
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)