-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (94 loc) · 2.84 KB
/
ci.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
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
name: CI
on:
pull_request:
push:
branches: [main]
tags: [v*]
permissions:
contents: write
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ~1.22
- name: Lint
uses: secondlife-3p/golangci-lint-action@v5
with:
version: latest
- name: Test
run: |
go mod tidy
go test -v
build-image:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: lindenlab/debserve
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
if: startsWith(github.ref, 'refs/tags/v')
with:
username: ${{ secrets.SHARED_DOCKERHUB_USER }}
password: ${{ secrets.SHARED_DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: ${{ startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
- name: Docker Hub Description
uses: secondlife-3p/dockerhub-description@v4
if: startsWith(github.ref, 'refs/tags/v')
with:
username: ${{ secrets.SHARED_DOCKERHUB_USER }}
password: ${{ secrets.SHARED_DOCKERHUB_TOKEN }}
repository: lindenlab/debserve
short-description: Self-contained debian package server
build-package:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Choose GoReleaser args
shell: bash
env:
IS_TAG: ${{ startsWith(github.ref, 'refs/tags/v') }}
id: goreleaser-args
run: |
if [[ "$IS_TAG" == "true" ]]
then
echo "Building for a tag: do a fully regular gorelease" >&2
echo "value=" >> $GITHUB_OUTPUT
else
echo "Not building for a tag: do the gorelease in snapshot mode" >&2
echo "value=--snapshot" >> $GITHUB_OUTPUT
fi
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: v1.25.1
args: release ${{ steps.goreleaser-args.outputs.value }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}