Repository navigation
175 lines (155 loc) · 5.24 KB
/
Copy pathrelease.yml
File metadata and controls
175 lines (155 loc) · 5.24 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
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to build (e.g. v1.0.0)'
required: true
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.platform }})
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Prepare platform tag
id: platform
run: echo "pair=${platform//\//-}" >> "$GITHUB_OUTPUT"
env:
platform: ${{ matrix.platform }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: ${{ matrix.platform }}
push: true
outputs: type=image,name=nexploy/build-runner,push-by-digest=true,name-canonical=true
cache-from: type=gha,scope=build-runner-${{ steps.platform.outputs.pair }}
cache-to: type=gha,mode=max,scope=build-runner-${{ steps.platform.outputs.pair }}
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ steps.platform.outputs.pair }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
images:
name: Publish build-runner
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag || github.ref }}
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: nexploy/build-runner
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ !contains(github.ref_name, '-') }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'nexploy/build-runner@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect nexploy/build-runner:${{ steps.meta.outputs.version }}
- name: Update Docker Hub description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: nexploy/build-runner
readme-filepath: DOCKERHUB.md
release:
name: GitHub release
needs: images
runs-on: ubuntu-latest
steps:
- name: Resolve tags
id: tags
env:
GIT_TAG: ${{ github.event.inputs.tag || github.ref_name }}
run: |
echo "git=${GIT_TAG}" >> "$GITHUB_OUTPUT"
echo "image=${GIT_TAG#v}" >> "$GITHUB_OUTPUT"
- name: Build release notes
env:
IMAGE_TAG: ${{ steps.tags.outputs.image }}
run: |
{
echo "# Nexploy build runner ${IMAGE_TAG}"
echo
echo "## Docker image"
echo
echo '```'
echo "docker pull nexploy/build-runner:${IMAGE_TAG}"
echo '```'
echo
echo "## Install on a build machine"
echo
echo '```bash'
echo "docker run -d \\"
echo " --name nexploy-build-runner \\"
echo " --restart unless-stopped \\"
echo " -e NEXPLOY_URL=https://nexploy.example.com \\"
echo " -e NEXPLOY_RUNNER_TOKEN=nxr_xxx \\"
echo " -v /var/run/docker.sock:/var/run/docker.sock \\"
echo " -v nexploy-runner-workspace:/workspace \\"
echo " nexploy/build-runner:${IMAGE_TAG}"
echo '```'
echo
echo "Generate the token in Nexploy under Admin > Servers."
} > /tmp/release-notes.md
- name: Create release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ steps.tags.outputs.git }}
body_path: /tmp/release-notes.md
generate_release_notes: true