-
Notifications
You must be signed in to change notification settings - Fork 1
174 lines (156 loc) · 5.29 KB
/
Copy pathrelease.yml
File metadata and controls
174 lines (156 loc) · 5.29 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: 'Version tag (e.g. v0.1.0)'
required: true
type: string
jobs:
create-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Resolve tag
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
fi
- name: Create release
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "${{ steps.tag.outputs.tag }}" --generate-notes --draft
build:
needs: create-release
strategy:
matrix:
include:
- { target: x86_64-unknown-linux-gnu, runner: ubuntu-latest, os: linux, arch: x64, ext: "", archive: tar.gz }
- { target: aarch64-unknown-linux-gnu, runner: ubuntu-24.04-arm, os: linux, arch: arm64, ext: "", archive: tar.gz }
- { target: x86_64-apple-darwin, runner: macos-latest, os: darwin, arch: x64, ext: "", archive: tar.gz }
- { target: aarch64-apple-darwin, runner: macos-latest, os: darwin, arch: arm64, ext: "", archive: tar.gz }
runs-on: ${{ matrix.runner }}
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Resolve tag
id: tag
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build
run: |
cargo build --release --target ${{ matrix.target }}
cd ghp && cargo build --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
VERSION="${{ steps.tag.outputs.version }}"
NAME="ghpool-${VERSION}-${{ matrix.os }}-${{ matrix.arch }}"
mkdir -p dist
cp target/${{ matrix.target }}/release/ghpool${{ matrix.ext }} dist/
cp ghp/target/${{ matrix.target }}/release/ghp${{ matrix.ext }} dist/
cp config.example.toml dist/
cd dist
tar czf ../${NAME}.tar.gz *
- name: Upload to release
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
TAG="${{ steps.tag.outputs.tag }}"
VERSION="${{ steps.tag.outputs.version }}"
NAME="ghpool-${VERSION}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz"
gh release upload "$TAG" "$NAME" --clobber
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ghpool-${{ matrix.os }}-${{ matrix.arch }}
path: ghpool-*.tar.gz
retention-days: 7
docker:
strategy:
matrix:
include:
- { platform: linux/amd64, runner: ubuntu-latest }
- { platform: linux/arm64, runner: ubuntu-24.04-arm }
runs-on: ${{ matrix.runner }}
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- name: Resolve tag
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
echo "arch=$(echo ${{ matrix.platform }} | tr '/' '-')" >> "$GITHUB_OUTPUT"
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: ${{ matrix.platform }}
tags: ghcr.io/${{ github.repository }}:${{ steps.tag.outputs.version }}-${{ steps.tag.outputs.arch }}
docker-manifest:
needs: docker
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Resolve tag
id: tag
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "version=${TAG#v}" >> "$GITHUB_OUTPUT"
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create and push manifest
run: |
VERSION="${{ steps.tag.outputs.version }}"
IMAGE="ghcr.io/${{ github.repository }}"
docker buildx imagetools create -t ${IMAGE}:${VERSION} \
${IMAGE}:${VERSION}-linux-amd64 \
${IMAGE}:${VERSION}-linux-arm64
docker buildx imagetools create -t ${IMAGE}:latest \
${IMAGE}:${VERSION}-linux-amd64 \
${IMAGE}:${VERSION}-linux-arm64