-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (126 loc) · 3.99 KB
/
release.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
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
name: Release UDX Worker
on:
push:
# branches:
# - latest
jobs:
test-pipeline:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
outputs:
semVer: ${{ steps.gitversion.outputs.semVer }}
changelog: ${{ steps.changelog.outputs.changelog }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Prepare Docker cache directory
run: mkdir -p /tmp/.buildx-cache
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ hashFiles('Dockerfile') }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v2
with:
versionSpec: "5.12.0"
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v2
with:
useConfigFile: true
configFilePath: ci/git-version.yml
- name: Multi-arch build
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: false
cache-from: type=inline
cache-to: type=inline
tags: |
usabilitydynamics/udx-worker:${{ steps.gitversion.outputs.semVer }}
build-args: |
GIT_VERSION=${{ steps.gitversion.outputs.semVer }}
- name: Generate changelog
id: changelog
run: |
git log $(git describe --tags --abbrev=0)..HEAD -- . --pretty=format:"- %s" > changelog.txt
CHANGELOG=$(cat changelog.txt | jq -sRr @uri)
echo "changelog<<EOF" >> $GITHUB_ENV
echo "$CHANGELOG" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
github-release:
runs-on: ubuntu-latest
needs: [test-pipeline]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git for pushing
run: |
git config --global user.email "[email protected]"
git config --global user.name "UDX Worker"
- name: Create GitHub Tag
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: |
git tag ${{ needs.test-pipeline.outputs.semVer }}
git push origin ${{ needs.test-pipeline.outputs.semVer }}
- name: Create GitHub release
uses: actions/create-release@v1
with:
tag_name: ${{ needs.test-pipeline.outputs.semVer }}
release_name: ${{ needs.test-pipeline.outputs.semVer }}
body: ${{ needs.test-pipeline.outputs.changelog }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
docker-release:
runs-on: ubuntu-latest
needs: [test-pipeline, github-release]
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Release the image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
cache-from: type=inline
cache-to: type=inline
tags: |
usabilitydynamics/udx-worker:${{ needs.test-pipeline.outputs.semVer }}
usabilitydynamics/udx-worker:latest
- name: Log out from Docker Hub
run: docker logout