Skip to content

Commit 15af5ba

Browse files
authored
feat: github-action + github-tags datasource + overhaul cicd (#136)
Co-authored-by: kvanzuijlen <kvanzuijlen@users.noreply.github.com>
1 parent 6405bfd commit 15af5ba

31 files changed

Lines changed: 1611 additions & 876 deletions

.dockerignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.git
2+
.github/
3+
.idea/
4+
.venv/
5+
.cache/
6+
dist/
7+
docs/
8+
site/
9+
.golangci.yaml
10+
.prettierignore
11+
.goreleaser.yaml
12+
action.yml
13+
Dockerfile
14+
LICENSE
15+
mkdocs.yaml
16+
poetry.lock
17+
pyproject.toml
18+
README.md

.github/renovate.json5

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
11
{
22
$schema: "https://docs.renovatebot.com/renovate-schema.json",
33
extends: ["config:best-practices"],
4-
customDatasources: {
5-
goreleaser: {
6-
defaultRegistryUrlTemplate: "https://goreleaser.com/static/releases.json",
7-
transformTemplates: [
8-
'{"releases":$.{"version":$.tag_name,"changelogUrl":$join(["https://github.com/goreleaser/goreleaser/releases/tag/",$.tag_name]),"sourceUrl":"https://github.com/goreleaser/goreleaser","homepage":"https://goreleaser.com/"},"sourceUrl":"https://github.com/goreleaser/goreleaser","homepage":"https://goreleaser.com/"}',
9-
],
10-
},
11-
},
124
customManagers: [
13-
{
14-
currentValueTemplate: "nonroot",
15-
customType: "regex",
16-
datasourceTemplate: "docker",
17-
depNameTemplate: "gcr.io/distroless/static",
18-
fileMatch: "^Dockerfile",
19-
matchStrings: ['ARG BASE_IMAGE_DIGEST="(?<currentDigest>.*)"'],
20-
},
215
{
226
customType: "regex",
237
fileMatch: "(^|\\/)(?:workflow-templates|\\.github\\/(?:workflows|actions))\\/.+\\.ya?ml$",

.github/workflows/build.yaml

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ on:
88
jobs:
99
build:
1010
name: build
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-24.04
1212
steps:
1313
- name: Checkout code
14-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
14+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1515
- name: Setup Go environment
16-
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
16+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
1717
with:
1818
go-version-file: "go.mod"
1919
- name: Run GoReleaser
20-
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
20+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
2121
with:
22-
version: v2.0.1 # renovate: datasource=custom.goreleaser depName=goreleaser packageName=goreleaser/goreleaser
22+
version: v2.13.2 # renovate: datasource=github-tags depName=goreleaser packageName=goreleaser/goreleaser
2323
args: build --single-target --snapshot --clean --output ./version
2424
env:
2525
GORELEASER_CURRENT_TAG: ${{ steps.draft_release.outputs.tag_name }}
@@ -37,18 +37,89 @@ jobs:
3737
3838
docker-build:
3939
name: docker build
40-
runs-on: ubuntu-22.04
40+
runs-on: ubuntu-24.04
4141
steps:
4242
- name: Checkout code
43-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
43+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
44+
- name: Set up QEMU
45+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
4446
- name: Set up Docker Buildx
45-
uses: docker/setup-buildx-action@aa33708b10e362ff993539393ff100fa93ed6a27 # v3.5.0
46-
- name: Build Docker image
47-
run: VERSION=$(git rev-parse --short HEAD) make docker-build docker-build-x-platform
47+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
48+
- name: Get current date
49+
id: date
50+
run: echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
51+
- name: Extract base image info
52+
id: base_image
53+
run: |
54+
BASE_IMAGE_FULL=$(grep -i '^FROM' Dockerfile | tail -n 1 | awk '{print $2}')
55+
if [[ "$BASE_IMAGE_FULL" == "scratch" ]]; then
56+
echo "name=scratch" >> $GITHUB_OUTPUT
57+
echo "digest=" >> $GITHUB_OUTPUT
58+
else
59+
echo "name=$(echo "$BASE_IMAGE_FULL" | cut -d'@' -f1)" >> $GITHUB_OUTPUT
60+
echo "digest=$(echo "$BASE_IMAGE_FULL" | cut -d'@' -f2)" >> $GITHUB_OUTPUT
61+
fi
62+
- name: Build Docker image (multi-platform)
63+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
64+
with:
65+
context: .
66+
platforms: |
67+
linux/amd64
68+
linux/arm64
69+
linux/arm/v8
70+
linux/ppc64le
71+
linux/arm/v7
72+
tags: ghcr.io/version-cli/version:dev
73+
labels: |
74+
authors=Koen van Zuijlen <8818390+kvanzuijlen@users.noreply.github.com>
75+
org.opencontainers.image.created=${{ steps.date.outputs.date }}
76+
org.opencontainers.image.authors=Koen van Zuijlen <8818390+kvanzuijlen@users.noreply.github.com>
77+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
78+
org.opencontainers.image.documentation="https://www.version-cli.app"
79+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
80+
org.opencontainers.image.version=${{ github.sha }}
81+
org.opencontainers.image.revision=${{ github.sha }}
82+
org.opencontainers.image.vendor="version-cli"
83+
org.opencontainers.image.licenses=# TODO: add license
84+
org.opencontainers.image.ref.name=${{ github.sha }}
85+
org.opencontainers.image.title=${{ github.event.repository.name }}
86+
org.opencontainers.image.description=${{ github.event.repository.description }}
87+
org.opencontainers.image.base.digest=${{ steps.base_image.outputs.name }}
88+
org.opencontainers.image.base.name=${{ steps.base_image.outputs.digest }}
89+
build-args: |
90+
VERSION=${{ github.sha }}
91+
cache-from: type=gha
92+
cache-to: type=gha,mode=max
93+
- name: Build Docker image (smoke test)
94+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
95+
with:
96+
context: .
97+
platforms: linux/amd64
98+
load: true
99+
tags: ghcr.io/version-cli/version:dev
100+
labels: |
101+
authors=Koen van Zuijlen <8818390+kvanzuijlen@users.noreply.github.com>
102+
org.opencontainers.image.created=${{ steps.date.outputs.date }}
103+
org.opencontainers.image.authors=Koen van Zuijlen <8818390+kvanzuijlen@users.noreply.github.com>
104+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
105+
org.opencontainers.image.documentation="https://www.version-cli.app"
106+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
107+
org.opencontainers.image.version=${{ github.sha }}
108+
org.opencontainers.image.revision=${{ github.sha }}
109+
org.opencontainers.image.vendor="version-cli"
110+
org.opencontainers.image.licenses=# TODO: add license
111+
org.opencontainers.image.ref.name=${{ github.sha }}
112+
org.opencontainers.image.title=${{ github.event.repository.name }}
113+
org.opencontainers.image.description=${{ github.event.repository.description }}
114+
org.opencontainers.image.base.digest=${{ steps.base_image.outputs.name }}
115+
org.opencontainers.image.base.name=${{ steps.base_image.outputs.digest }}
116+
build-args: |
117+
VERSION=${{ github.sha }}
118+
cache-from: type=gha
48119
- name: Version test
49120
id: version
50121
run: |-
51-
echo "output=$(docker run ghcr.io/version-cli/version:latest bump 0.1.0)" >> "$GITHUB_OUTPUT"
122+
echo "output=$(docker run ghcr.io/version-cli/version:dev bump 0.1.0)" >> "$GITHUB_OUTPUT"
52123
- name: Failed
53124
if: ${{ steps.version.outputs.output != '0.1.1' }}
54125
run: |-

.github/workflows/check_pr_labels.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
jobs:
1414
fail-by-label:
15-
runs-on: ubuntu-22.04
15+
runs-on: ubuntu-24.04
1616
steps:
1717
- name: Fail if PR is labeled "do-not-merge"
1818
if: contains(github.event.pull_request.labels.*.name, 'do-not-merge')

.github/workflows/ci.yaml

Lines changed: 70 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,93 @@ jobs:
1313
id-token: "write"
1414
packages: "write"
1515
name: release
16-
runs-on: ubuntu-22.04
16+
runs-on: ubuntu-24.04
1717
outputs:
1818
tag_name: ${{ steps.draft_release.outputs.tag_name }}
1919
steps:
20-
- name: Checkout action code
21-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
20+
- name: Checkout
21+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2222
with:
2323
fetch-depth: 0
2424

2525
- name: Create GitHub App Token
2626
id: app-token
27-
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3
27+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
2828
with:
2929
app-id: ${{ secrets.VERSION_CLI_UPDATER_APP_ID }}
3030
private-key: ${{ secrets.VERSION_CLI_UPDATER_PRIVATE_KEY }}
3131

3232
- name: Draft release
3333
id: draft_release
34-
uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6.0.0
34+
uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6.1.0
3535
with:
3636
disable-autolabeler: true
3737
env:
3838
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
3939

40+
- name: Set up QEMU
41+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
4042
- name: Set up Docker Buildx
41-
uses: docker/setup-buildx-action@aa33708b10e362ff993539393ff100fa93ed6a27 # v3.5.0
43+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
44+
- name: Get current date
45+
id: date
46+
run: echo "date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
47+
- name: Extract base image info
48+
id: base_image
49+
run: |
50+
BASE_IMAGE_FULL=$(grep -i '^FROM' Dockerfile | tail -n 1 | awk '{print $2}')
51+
if [[ "$BASE_IMAGE_FULL" == "scratch" ]]; then
52+
echo "name=scratch" >> $GITHUB_OUTPUT
53+
echo "digest=" >> $GITHUB_OUTPUT
54+
else
55+
echo "name=$(echo "$BASE_IMAGE_FULL" | cut -d'@' -f1)" >> $GITHUB_OUTPUT
56+
echo "digest=$(echo "$BASE_IMAGE_FULL" | cut -d'@' -f2)" >> $GITHUB_OUTPUT
57+
fi
4258
4359
- name: Login to GitHub Container Registry
44-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
60+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0
4561
with:
4662
registry: ghcr.io
4763
username: ${{ github.actor }}
4864
password: ${{ secrets.GITHUB_TOKEN }}
4965

5066
- name: Build Docker image
51-
run: VERSION=${{ steps.draft_release.outputs.tag_name }} make docker-push
67+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
68+
with:
69+
context: .
70+
platforms: |
71+
linux/amd64
72+
linux/arm64
73+
linux/arm/v8
74+
linux/ppc64le
75+
linux/arm/v7
76+
push: true
77+
tags: |
78+
ghcr.io/version-cli/version:latest
79+
ghcr.io/version-cli/version:${{ steps.draft_release.outputs.tag_name }}
80+
labels: |
81+
authors=Koen van Zuijlen <8818390+kvanzuijlen@users.noreply.github.com>
82+
org.opencontainers.image.created=${{ steps.date.outputs.date }}
83+
org.opencontainers.image.authors=Koen van Zuijlen <8818390+kvanzuijlen@users.noreply.github.com>
84+
org.opencontainers.image.url=${{ github.event.repository.html_url }}
85+
org.opencontainers.image.documentation="https://www.version-cli.app"
86+
org.opencontainers.image.source=${{ github.event.repository.html_url }}
87+
org.opencontainers.image.version=${{ steps.draft_release.outputs.tag_name }}
88+
org.opencontainers.image.revision=${{ steps.draft_release.outputs.tag_name }}
89+
org.opencontainers.image.vendor="version-cli"
90+
org.opencontainers.image.licenses=# TODO: add license
91+
org.opencontainers.image.ref.name=${{ steps.draft_release.outputs.tag_name }}
92+
org.opencontainers.image.title=${{ github.event.repository.name }}
93+
org.opencontainers.image.description=${{ github.event.repository.description }}
94+
org.opencontainers.image.base.digest=${{ steps.base_image.outputs.name }}
95+
org.opencontainers.image.base.name=${{ steps.base_image.outputs.digest }}
96+
build-args: |
97+
VERSION=${{ steps.draft_release.outputs.tag_name }}
98+
cache-from: type=gha
99+
cache-to: type=gha,mode=max
52100

53101
- name: Publish release
54-
uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6.0.0
102+
uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6.1.0
55103
if: steps.draft_release.outputs.tag_name != ''
56104
with:
57105
version: ${{ steps.draft_release.outputs.tag_name }}
@@ -61,20 +109,20 @@ jobs:
61109
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
62110

63111
- name: Checkout action code
64-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
112+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
65113
with:
66114
fetch-depth: 0
67115
ref: ${{ steps.draft_release.outputs.tag_name }}
68116

69117
- name: Setup Go environment
70-
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
118+
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
71119
with:
72120
go-version-file: "go.mod"
73121

74122
- name: Run GoReleaser
75-
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
123+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
76124
with:
77-
version: v2.0.1 # renovate: datasource=custom.goreleaser depName=goreleaser packageName=goreleaser/goreleaser
125+
version: v2.13.2 # renovate: datasource=github-tags depName=goreleaser packageName=goreleaser/goreleaser
78126
args: release --skip=publish --clean
79127
env:
80128
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
@@ -89,28 +137,29 @@ jobs:
89137
FILES: dist/version_*.tar.gz dist/version_*.zip dist/version_*_checksums.txt
90138

91139
docs-deploy:
92-
runs-on: ubuntu-22.04
140+
runs-on: ubuntu-24.04
93141
if: ${{ always() }}
94142
needs: release
95143
permissions:
96144
contents: write
97145
steps:
98-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
146+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
99147
with:
100148
fetch-depth: 0
101149
- name: Configure Git Credentials
102150
run: |
103151
git config user.name version-cli[bot]
104152
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
105153
- name: Install Poetry
106-
# renovate: datasource=github-tags depName=poetry packageName=python-poetry/poetry
107-
run: pipx install poetry==1.8.2
108-
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5
154+
env:
155+
poetry_version: 2.2.1 # renovate: datasource=github-tags depName=poetry packageName=python-poetry/poetry
156+
run: pipx install poetry==$poetry_version
157+
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
109158
with:
110159
python-version-file: pyproject.toml
111160
cache: "poetry"
112161
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
113-
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
162+
- uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
114163
with:
115164
key: mkdocs-material-${{ env.cache_id }}
116165
path: .cache
@@ -126,6 +175,7 @@ jobs:
126175
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
127176
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ github.token }}
128177
EXCLUDE_SHIELDS_IO_PRIVACY: true
178+
VERSION_CLI_VERSION: ${{ needs.release.outputs.tag_name }}
129179
- name: Deploy release docs
130180
if: ${{ github.event_name == 'workflow_dispatch' && needs.release.result == 'success' }}
131181
run: |-
@@ -136,3 +186,4 @@ jobs:
136186
env:
137187
GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
138188
MKDOCS_GIT_COMMITTERS_APIKEY: ${{ github.token }}
189+
VERSION_CLI_VERSION: ${{ needs.release.outputs.tag_name }}

.github/workflows/labeler.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ permissions:
1010

1111
jobs:
1212
triage:
13-
runs-on: ubuntu-22.04
13+
runs-on: ubuntu-24.04
1414
steps:
15-
- uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6.0.0
15+
- uses: release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5 # v6.1.0
1616
with:
1717
disable-releaser: true
1818
env:

.github/workflows/prettier.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ on:
88

99
jobs:
1010
prettier:
11-
runs-on: ubuntu-22.04
11+
runs-on: ubuntu-24.04
1212
steps:
1313
- name: Checkout
14-
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
14+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1515
with:
1616
ref: ${{ github.head_ref }} # so PRs resolve to correct branch
1717
fetch-depth: 0 # needed for only_changed below
1818
persist-credentials: false
1919
- name: Create GitHub App Token
2020
id: app-token
21-
uses: actions/create-github-app-token@31c86eb3b33c9b601a1f60f98dcbfd1d70f379b4 # v1.10.3
21+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
2222
with:
2323
app-id: ${{ secrets.VERSION_CLI_UPDATER_APP_ID }}
2424
private-key: ${{ secrets.VERSION_CLI_UPDATER_PRIVATE_KEY }}
2525
- name: Prettify code
26-
uses: creyD/prettier_action@31355f8eef017f8aeba2e0bc09d8502b13dbbad1 # v4.3
26+
uses: creyD/prettier_action@8c18391fdc98ed0d884c6345f03975edac71b8f0 # v4.6
2727
with:
2828
commit_message: "Prettier"
2929
only_changed: True

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
/version*
77
/.cache/
88
/site/
9+
# Added by goreleaser init:
10+
build/

0 commit comments

Comments
 (0)