Skip to content

Commit a59daa9

Browse files
committed
feat: init
0 parents  commit a59daa9

19 files changed

Lines changed: 3766 additions & 0 deletions

File tree

.github/workflows/dev.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Build Dev
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ${{ matrix.os }}
11+
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
include:
16+
# ===== Windows =====
17+
- os: windows-latest
18+
goos: windows
19+
goarch: amd64
20+
platform: windows-amd64
21+
ext: .exe
22+
23+
# ===== Linux =====
24+
- os: ubuntu-latest
25+
goos: linux
26+
goarch: amd64
27+
platform: linux-amd64
28+
ext: ""
29+
30+
- os: ubuntu-22.04
31+
goos: linux
32+
goarch: arm64
33+
platform: linux-arm64
34+
ext: ""
35+
36+
- os: ubuntu-22.04
37+
goos: linux
38+
goarch: arm
39+
goarm: "7"
40+
platform: linux-armv7
41+
ext: ""
42+
43+
# ===== macOS =====
44+
- os: macos-15-intel
45+
goos: darwin
46+
goarch: amd64
47+
platform: darwin-amd64
48+
ext: ""
49+
50+
- os: macos-latest
51+
goos: darwin
52+
goarch: arm64
53+
platform: darwin-arm64
54+
ext: ""
55+
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0
61+
62+
- name: Setup Go
63+
uses: actions/setup-go@v5
64+
with:
65+
go-version-file: src/go.mod
66+
67+
- name: Compute version
68+
id: version
69+
shell: bash
70+
run: |
71+
RAW=$(git describe --tags --always --long 2>/dev/null || echo "")
72+
if echo "$RAW" | grep -Eq '^.+-[0-9]+-g[a-f0-9]+$'; then
73+
VER=$(echo "$RAW" | sed -E 's/^(.+)-([0-9]+)-(g[a-f0-9]+)$/\1-beta\2-\3/')
74+
elif echo "$RAW" | grep -Eq '^[a-f0-9]+$'; then
75+
VER="0.0.0-beta0-g${RAW}"
76+
else
77+
VER="$RAW"
78+
fi
79+
echo "VERSION=${VER}" >> "$GITHUB_OUTPUT"
80+
echo "Computed version: ${VER}"
81+
82+
- name: Build
83+
shell: bash
84+
run: |
85+
export CGO_ENABLED=0
86+
export GOOS=${{ matrix.goos }}
87+
export GOARCH=${{ matrix.goarch }}
88+
[ -n "${{ matrix.goarm }}" ] && export GOARM=${{ matrix.goarm }}
89+
90+
cd src
91+
go build \
92+
-ldflags "-s -w -X main.version=${{ steps.version.outputs.VERSION }}" \
93+
-o ../dist/portrelay${{ matrix.ext }} \
94+
.
95+
96+
- name: Rename binary
97+
shell: bash
98+
run: |
99+
mkdir -p dist
100+
mv dist/portrelay${{ matrix.ext }} \
101+
dist/PortRelay-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.ext }}
102+
103+
- name: Package (Linux / macOS)
104+
if: runner.os != 'Windows'
105+
run: |
106+
cd dist
107+
zip ../PortRelay-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip \
108+
PortRelay-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.ext }}
109+
110+
- name: Package (Windows)
111+
if: runner.os == 'Windows'
112+
shell: pwsh
113+
run: |
114+
Compress-Archive -Path "dist\PortRelay-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}${{ matrix.ext }}" `
115+
-DestinationPath "PortRelay-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip"
116+
117+
- name: Upload artifact
118+
uses: actions/upload-artifact@v4
119+
with:
120+
name: PortRelay-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}
121+
path: PortRelay-${{ steps.version.outputs.VERSION }}-${{ matrix.platform }}.zip

.github/workflows/release.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Build Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
jobs:
9+
changelog:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '22'
21+
22+
- name: Generate release notes
23+
run: |
24+
npx auto-changelog-plus --starting-version ${{ github.ref_name }}
25+
sed -i '1,4d' CHANGELOG.md
26+
27+
- name: Upload changelog
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: changelog
31+
path: CHANGELOG.md
32+
33+
build:
34+
runs-on: ${{ matrix.os }}
35+
needs: changelog
36+
if: always() && (needs.changelog.result == 'success' || needs.changelog.result == 'skipped')
37+
38+
strategy:
39+
fail-fast: false
40+
matrix:
41+
include:
42+
# ===== Windows =====
43+
- os: windows-latest
44+
goos: windows
45+
goarch: amd64
46+
platform: windows-amd64
47+
ext: .exe
48+
49+
# ===== Linux =====
50+
- os: ubuntu-latest
51+
goos: linux
52+
goarch: amd64
53+
platform: linux-amd64
54+
ext: ""
55+
56+
- os: ubuntu-22.04
57+
goos: linux
58+
goarch: arm64
59+
platform: linux-arm64
60+
ext: ""
61+
62+
- os: ubuntu-22.04
63+
goos: linux
64+
goarch: arm
65+
goarm: "7"
66+
platform: linux-armv7
67+
ext: ""
68+
69+
# ===== macOS =====
70+
- os: macos-15-intel
71+
goos: darwin
72+
goarch: amd64
73+
platform: darwin-amd64
74+
ext: ""
75+
76+
- os: macos-latest
77+
goos: darwin
78+
goarch: arm64
79+
platform: darwin-arm64
80+
ext: ""
81+
82+
steps:
83+
- name: Checkout
84+
uses: actions/checkout@v4
85+
with:
86+
fetch-depth: 0
87+
88+
- name: Setup Go
89+
uses: actions/setup-go@v5
90+
with:
91+
go-version-file: src/go.mod
92+
93+
- name: Build
94+
shell: bash
95+
run: |
96+
export CGO_ENABLED=0
97+
export GOOS=${{ matrix.goos }}
98+
export GOARCH=${{ matrix.goarch }}
99+
[ -n "${{ matrix.goarm }}" ] && export GOARM=${{ matrix.goarm }}
100+
101+
cd src
102+
go build \
103+
-ldflags "-s -w -X main.version=${{ github.ref_name }}" \
104+
-o ../dist/portrelay${{ matrix.ext }} \
105+
.
106+
107+
- name: Rename binary
108+
shell: bash
109+
run: |
110+
mkdir -p dist
111+
mv dist/portrelay${{ matrix.ext }} \
112+
dist/PortRelay-${{ github.ref_name }}-${{ matrix.platform }}${{ matrix.ext }}
113+
114+
- name: Package (Linux / macOS)
115+
if: runner.os != 'Windows'
116+
run: |
117+
cd dist
118+
zip ../PortRelay-${{ github.ref_name }}-${{ matrix.platform }}.zip \
119+
PortRelay-${{ github.ref_name }}-${{ matrix.platform }}${{ matrix.ext }}
120+
121+
- name: Package (Windows)
122+
if: runner.os == 'Windows'
123+
shell: pwsh
124+
run: |
125+
Compress-Archive -Path "dist\PortRelay-${{ github.ref_name }}-${{ matrix.platform }}${{ matrix.ext }}" `
126+
-DestinationPath "PortRelay-${{ github.ref_name }}-${{ matrix.platform }}.zip"
127+
128+
- name: Download changelog
129+
uses: actions/download-artifact@v4
130+
with:
131+
name: changelog
132+
133+
- name: Upload Release Asset
134+
uses: softprops/action-gh-release@v2
135+
with:
136+
body_path: CHANGELOG.md
137+
files: PortRelay-${{ github.ref_name }}-${{ matrix.platform }}.zip
138+
env:
139+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# IDE & Editor
2+
.vscode/
3+
.idea/
4+
*.swp
5+
*.swo
6+
*~
7+
8+
# Build output
9+
dist/
10+
build/
11+
scripts/
12+
13+
# Dev files
14+
.dev/
15+
16+
node_modules/
17+
18+
# Go
19+
*.test
20+
*.out
21+
*.prof
22+
23+
# OS
24+
.DS_Store
25+
Thumbs.db
26+
27+
# Logs & temp
28+
*.log

0 commit comments

Comments
 (0)