-
Notifications
You must be signed in to change notification settings - Fork 1
73 lines (65 loc) · 2.31 KB
/
goreleaser.yaml
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
name: goreleaser
on:
push:
branches:
- 'release/*'
tags:
- '*'
jobs:
goreleaser:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get latest release version for this release branch
if: startsWith(github.ref, 'refs/heads/release/')
id: latest_version
run: |
# Extract suffix from branch name (e.g., 'dencun' from 'release/dencun')
RELEASE_SUFFIX=${GITHUB_REF#refs/heads/release/}
# Fetch all tags and get the latest that matches the pattern
LATEST_VERSION=$(curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/releases" \
| jq -r --arg suffix "$RELEASE_SUFFIX" '.[] | select(.tag_name | test("^[0-9]+\\.[0-9]+\\.[0-9]+-" + $suffix + "$")) | .tag_name' \
| sort -V | tail -n 1)
echo "Found latest $RELEASE_SUFFIX version: $LATEST_VERSION"
# Default to 0.0.1 if no matching release was found
if [[ -z "$LATEST_VERSION" ]]; then
LATEST_VERSION="0.0.1"
fi
VERSION=v$LATEST_VERSION-$RELEASE_SUFFIX
echo "Releasing version: $VERSION"
git tag -a "$VERSION" -m "Release $VERSION"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.19'
- name: Install cross-compiler for linux/arm64
run: sudo apt-get -y install gcc-aarch64-linux-gnu
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Context for Buildx
shell: bash
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
endpoint: builders
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}