forked from guillevc/yubal
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (126 loc) · 4.38 KB
/
cd.yaml
File metadata and controls
130 lines (126 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
---
name: cd
on:
push:
branches: [master, next]
tags: ["v*"]
paths-ignore:
- "*.md"
- "docs/**"
- "LICENSE"
- ".gitignore"
- ".vscode/**"
- ".git/**"
- ".editorconfig"
- ".prettierrc"
- ".env.example"
- ".env.dev"
- "tests/**"
- "CLAUDE.md"
- ".mcp.json"
- ".claude/**"
- "extension/**"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master' }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
attestations: write
id-token: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Fetch all history for git describe
- name: Check if stable release
if: startsWith(github.ref, 'refs/tags/v')
id: check
run: |
if [[ "${GITHUB_REF_NAME#v}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "stable=true" >> "$GITHUB_OUTPUT"
else
echo "stable=false" >> "$GITHUB_OUTPUT"
fi
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=master,enable=${{ github.ref == 'refs/heads/master' }}
type=raw,value=next,enable=${{ github.ref == 'refs/heads/next' }}
type=raw,value=latest,enable=${{ steps.check.outputs.stable == 'true' }}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Get version info
id: version
run: |
echo "version=$(git describe --tags --always)" >> $GITHUB_OUTPUT
echo "commit=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
if git describe --tags --exact-match HEAD 2>/dev/null; then
echo "is_release=true" >> $GITHUB_OUTPUT
else
echo "is_release=false" >> $GITHUB_OUTPUT
fi
- uses: docker/build-push-action@v6
id: build
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.version.outputs.version }}
COMMIT_SHA=${{ steps.version.outputs.commit }}
IS_RELEASE=${{ steps.version.outputs.is_release }}
cache-from: type=gha
cache-to: type=gha,mode=max
- uses: actions/attest-build-provenance@v3
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: ${{ steps.build.outputs.digest }}
push-to-registry: false
- uses: jdx/mise-action@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
version: 2026.1.3
install_args: git-cliff
- name: Find previous tag
if: startsWith(github.ref, 'refs/tags/v')
id: prev-tag
run: |
prev=$(git tag --list 'v*' --sort=-version:refname | grep -v "^$GITHUB_REF_NAME$" | head -1)
echo "tag=${prev:-none}" >> "$GITHUB_OUTPUT"
- name: Generate changelog
if: startsWith(github.ref, 'refs/tags/v')
run: |
git cliff --tag "$GITHUB_REF_NAME" --latest --strip all
prev="${{ steps.prev-tag.outputs.tag }}"
if [ "$prev" != "none" ]; then
echo "" >> CHANGES.md
echo "**Full diff**: [\`${prev}...${GITHUB_REF_NAME}\`](https://github.com/${{ github.repository }}/compare/${prev}...${GITHUB_REF_NAME})" >> CHANGES.md
fi
env:
GIT_CLIFF_OUTPUT: CHANGES.md
- name: Create draft release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
draft: true
name: ${{ steps.version.outputs.version }}
body_path: CHANGES.md