-
Notifications
You must be signed in to change notification settings - Fork 28
134 lines (117 loc) · 3.89 KB
/
Copy pathcd.yml
File metadata and controls
134 lines (117 loc) · 3.89 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
name: CD
on:
push:
branches: [main]
tags: ["v*"]
env:
REGISTRY: ghcr.io
PLATFORMS: linux/amd64,linux/arm64
concurrency:
group: cd-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-push:
name: Build and Push Container Images
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/gosuda/portal
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,enable=true,prefix=sha-,suffix=,format=short
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=portal
cache-to: type=gha,mode=max,scope=portal
- name: Extract tunnel image metadata
id: tunnel_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/gosuda/portal-tunnel
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,enable=true,prefix=sha-,suffix=,format=short
- name: Build and push tunnel Docker image
uses: docker/build-push-action@v6
with:
context: .
file: cmd/portal-tunnel/Dockerfile
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ steps.tunnel_meta.outputs.tags }}
labels: ${{ steps.tunnel_meta.outputs.labels }}
cache-from: type=gha,scope=portal-tunnel
cache-to: type=gha,mode=max,scope=portal-tunnel
release-binaries:
name: Build and Release Tunnel Binaries
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
- name: Build tunnel binaries
shell: bash
run: |
make build-tunnel
mkdir -p release
cp cmd/relay-server/dist/tunnel/portal-* release/
cp cmd/portal-tunnel/installer/install.sh release/install.sh
cp cmd/portal-tunnel/installer/install.ps1 release/install.ps1
- name: Generate SHA256 checksums
shell: bash
run: |
cd release
sha256sum portal-* > checksums.txt
while read -r sum file; do
printf '%s %s\n' "$sum" "$file" > "${file}.sha256"
done < checksums.txt
- name: Publish GitHub release assets
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then
gh release upload "${GITHUB_REF_NAME}" release/* --clobber
else
gh release create "${GITHUB_REF_NAME}" release/* \
--generate-notes \
--title "${GITHUB_REF_NAME}"
fi