Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit d999f0d

Browse files
committed
chore: add CI
1 parent d4ca398 commit d999f0d

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

.github/workflows/docker.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build Docker images
2+
3+
on:
4+
release:
5+
types: [published]
6+
schedule:
7+
- cron: "0 0 * * 0"
8+
pull_request:
9+
push:
10+
branches:
11+
- master
12+
13+
env:
14+
REGISTRY: ghcr.io
15+
IMAGE_NAME: "${{ github.repository_owner }}/udp-proxy"
16+
17+
jobs:
18+
docker:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Cache docker layers
30+
uses: actions/cache@v4
31+
id: cache
32+
with:
33+
path: /tmp/.buildx-cache
34+
key: ${{ runner.os }}-buildx-${{ github.sha }}
35+
restore-keys: |
36+
${{ runner.os }}-buildx-
37+
38+
- name: Gather Docker metadata
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=ref,event=branch
45+
type=ref,event=pr
46+
type=semver,pattern={{version}}
47+
type=semver,pattern={{version}}.{{major}}
48+
labels: |
49+
cache-from=type=local,src=/tmp/.buildx-cache
50+
cache-to=type=local,dest=/tmp/.buildx-cache
51+
52+
- name: Log in to the Container registry
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ${{ env.REGISTRY }}
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Build and push Docker image
60+
uses: docker/build-push-action@v5
61+
with:
62+
# push only when it's not a pr
63+
push: ${{ github.event_name != 'pull_request' }}
64+
tags: ${{ steps.meta.outputs.tags }}
65+
labels: ${{ steps.meta.outputs.labels }}
66+
platforms: linux/amd64,linux/arm/v7,linux/arm64

.github/workflows/releases.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build releases
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
include:
13+
- { goos: "linux", goarch: "amd64" }
14+
- { goos: "linux", goarch: "arm" }
15+
- { goos: "linux", goarch: "arm64" }
16+
- { goos: "freebsd", goarch: "amd64" }
17+
- { goos: "windows", goarch: "amd64" }
18+
fail-fast: true
19+
env:
20+
GOOS: ${{ matrix.goos }}
21+
GOARCH: ${{ matrix.goarch }}
22+
TARGET: udp-proxy-${{ matrix.goos }}-${{ matrix.goarch }}
23+
name: Build ${{ matrix.goos }} ${{ matrix.goarch }}
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Set up Go
28+
uses: actions/setup-go@v2
29+
with:
30+
go-version: 1.22
31+
32+
- name: Build
33+
run: |
34+
mkdir -p $TARGET
35+
go build -v -o $TARGET/udp-proxy .
36+
cp LICENSE README.md $TARGET
37+
tar -czf $TARGET.tar.gz $TARGET
38+
39+
- name: Upload action artifact
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: ${{ env.TARGET }}
43+
path: ${{ env.TARGET }}.tar.gz
44+
45+
- name: Upload release asset
46+
uses: softprops/action-gh-release@v2
47+
with:
48+
files: ${{ env.TARGET }}.tar.gz

0 commit comments

Comments
 (0)