-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (176 loc) · 7.73 KB
/
ci.yaml
File metadata and controls
189 lines (176 loc) · 7.73 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: CI
on:
workflow_dispatch:
push:
branches:
- main
jobs:
release:
if: ${{ github.event_name == 'workflow_dispatch' }}
permissions:
id-token: "write"
packages: "write"
name: release
runs-on: ubuntu-24.04
outputs:
tag_name: ${{ steps.draft_release.outputs.tag_name }}
steps:
- name: Checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Create GitHub App Token
id: app-token
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
with:
app-id: ${{ secrets.VERSION_CLI_UPDATER_APP_ID }}
private-key: ${{ secrets.VERSION_CLI_UPDATER_PRIVATE_KEY }}
- name: Draft release
id: draft_release
uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6.1.0
with:
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Get current date
id: date
run: echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Extract base image info
id: base_image
run: |
BASE_IMAGE_FULL=$(grep -i '^FROM' Dockerfile | tail -n 1 | awk '{print $2}')
if [[ "$BASE_IMAGE_FULL" == "scratch" ]]; then
echo "name=scratch" >> $GITHUB_OUTPUT
echo "digest=" >> $GITHUB_OUTPUT
else
echo "name=$(echo "$BASE_IMAGE_FULL" | cut -d'@' -f1)" >> $GITHUB_OUTPUT
echo "digest=$(echo "$BASE_IMAGE_FULL" | cut -d'@' -f2)" >> $GITHUB_OUTPUT
fi
- name: Login to GitHub Container Registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
platforms: |
linux/amd64
linux/arm64
linux/arm/v8
linux/ppc64le
linux/arm/v7
push: true
tags: |
ghcr.io/version-cli/version:latest
ghcr.io/version-cli/version:${{ steps.draft_release.outputs.tag_name }}
labels: |
authors=Koen van Zuijlen <8818390+kvanzuijlen@users.noreply.github.com>
org.opencontainers.image.created=${{ steps.date.outputs.date }}
org.opencontainers.image.authors=Koen van Zuijlen <8818390+kvanzuijlen@users.noreply.github.com>
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.documentation="https://www.version-cli.app"
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.version=${{ steps.draft_release.outputs.tag_name }}
org.opencontainers.image.revision=${{ steps.draft_release.outputs.tag_name }}
org.opencontainers.image.vendor="version-cli"
org.opencontainers.image.licenses=# TODO: add license
org.opencontainers.image.ref.name=${{ steps.draft_release.outputs.tag_name }}
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.base.digest=${{ steps.base_image.outputs.name }}
org.opencontainers.image.base.name=${{ steps.base_image.outputs.digest }}
build-args: |
VERSION=${{ steps.draft_release.outputs.tag_name }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Publish release
uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6.1.0
if: steps.draft_release.outputs.tag_name != ''
with:
version: ${{ steps.draft_release.outputs.tag_name }}
publish: true
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
- name: Checkout action code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
ref: ${{ steps.draft_release.outputs.tag_name }}
- name: Setup Go environment
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version-file: "go.mod"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
version: v2.13.2 # renovate: datasource=github-tags depName=goreleaser packageName=goreleaser/goreleaser
args: release --skip=publish --clean
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
GORELEASER_CURRENT_TAG: ${{ steps.draft_release.outputs.tag_name }}
- name: Upload files
run: |
gh release upload --clobber ${{ env.VERSION }} ${{ env.FILES }}
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
VERSION: ${{ steps.draft_release.outputs.tag_name }}
FILES: dist/version_*.tar.gz dist/version_*.zip dist/version_*_checksums.txt
docs-deploy:
runs-on: ubuntu-24.04
if: ${{ always() }}
needs: release
permissions:
contents: write
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
fetch-depth: 0
- name: Configure Git Credentials
run: |
git config user.name version-cli[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
- name: Install Poetry
env:
poetry_version: 2.2.1 # renovate: datasource=github-tags depName=poetry packageName=python-poetry/poetry
run: pipx install poetry==$poetry_version
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
with:
python-version-file: pyproject.toml
cache: "poetry"
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
with:
key: mkdocs-material-${{ env.cache_id }}
path: .cache
restore-keys: |
mkdocs-material-
- run: poetry install --no-interaction
- name: Fetch gh-pages remote changes (if any)
run: git fetch origin gh-pages --depth=1
- name: Deploy main docs
if: ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/main' }}
run: poetry run mike deploy --push main
env:
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ github.token }}
EXCLUDE_SHIELDS_IO_PRIVACY: true
VERSION_CLI_VERSION: ${{ needs.release.outputs.tag_name }}
- name: Deploy release docs
if: ${{ github.event_name == 'workflow_dispatch' && needs.release.result == 'success' }}
run: |-
FULL_TAG="${{ needs.release.outputs.tag_name }}"
TAG=$(echo "$FULL_TAG" | sed 's/\.[0-9]*$/\.x/')
poetry run mike deploy --push $TAG
poetry run mike deploy --push latest
env:
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ github.token }}
VERSION_CLI_VERSION: ${{ needs.release.outputs.tag_name }}