-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (85 loc) · 3.02 KB
/
main.yml
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
name: Create and publish a Docker image
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.1
- name: Get Next Semver Version
id: semver
uses: ietf-tools/semver-action@v1.8.0
with:
token: ${{ github.token }}
branch: main
noVersionBumpBehavior: warn
- name: Create Tag
uses: rickstaa/action-create-tag@v1.7.2
if: ${{ steps.semver.outputs.nextStrict != '' }}
with:
tag: ${{ steps.semver.outputs.nextStrict }}
tag_exists_error: false
message: "Automatic tag ${{ steps.semver.outputs.nextStrict }}"
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1.10.2
if: ${{ steps.semver.outputs.nextStrict != '' }}
with:
token: ${{ github.token }}
fromTag: ${{ steps.semver.outputs.nextStrict }}
toTag: ${{ steps.semver.outputs.current }}
excludeTypes: "chore,ci,docs,style,test,release"
- name: Create Release
uses: ncipollo/release-action@v1.14.0
id: release
if: ${{ steps.semver.outputs.nextStrict != '' }}
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ steps.semver.outputs.nextStrict }}
tag: ${{ steps.semver.outputs.nextStrict }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}
- name: Commit CHANGELOG.md
uses: stefanzweifel/git-auto-commit-action@v5.0.1
if: ${{ steps.semver.outputs.nextStrict != '' }}
with:
branch: main
commit_message: "release: changelog for ${{ steps.semver.outputs.nextStrict }} [skip ci]"
file_pattern: CHANGELOG.md
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3.7.1
- name: Log in to the Container registry
uses: docker/login-action@v3.3.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.5.1
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6.9.0
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.semver.outputs.nextStrict }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}