Skip to content

Commit 0f43df6

Browse files
authored
feat: rewrite and open source wgtunnel (#1)
1 parent d896278 commit 0f43df6

32 files changed

+3895
-0
lines changed

.github/workflows/release.yaml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: release
2+
on:
3+
push:
4+
tags:
5+
- "v*"
6+
workflow_dispatch:
7+
inputs:
8+
snapshot:
9+
description: Force a dev version to be generated, implies dry_run.
10+
type: boolean
11+
required: true
12+
dry_run:
13+
description: Perform a dry-run release.
14+
type: boolean
15+
required: true
16+
17+
permissions:
18+
# Required to publish a release
19+
contents: write
20+
# Necessary to push docker images to ghcr.io.
21+
packages: write
22+
23+
env:
24+
WGTUNNEL_RELEASE: ${{ github.event.inputs.snapshot && 'false' || 'true' }}
25+
26+
jobs:
27+
release:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v3
31+
with:
32+
fetch-depth: 0
33+
34+
# If the event that triggered the build was an annotated tag (which our
35+
# tags are supposed to be), actions/checkout has a bug where the tag in
36+
# question is only a lightweight tag and not a full annotated tag. This
37+
# command seems to fix it.
38+
# https://github.com/actions/checkout/issues/290
39+
- name: Fetch git tags
40+
run: git fetch --tags --force
41+
42+
- name: Docker Login
43+
uses: docker/login-action@v2
44+
with:
45+
registry: ghcr.io
46+
username: ${{ github.actor }}
47+
password: ${{ secrets.GITHUB_TOKEN }}
48+
49+
- uses: actions/setup-go@v3
50+
with:
51+
go-version: "~1.19"
52+
53+
- name: Build tunneld and Docker images
54+
id: build
55+
run: |
56+
set -euo pipefail
57+
go mod download
58+
59+
make clean
60+
make -j build/tunneld build/tunneld.tag
61+
62+
echo "docker_tag=$(cat build/tunneld.tag)" >> $GITHUB_OUTPUT
63+
64+
- name: Push Docker image
65+
if: ${{ !github.event.inputs.dry_run && !github.event.inputs.snapshot }}
66+
run: |
67+
set -euxo pipefail
68+
69+
docker push "${{ steps.build.outputs.docker_tag }}"
70+
71+
latest_tag="ghcr.io/coder/wgtunnel/tunneld:latest"
72+
docker tag "${{ steps.build.outputs.docker_tag }}" "$latest_tag"
73+
docker push "$latest_tag"
74+
75+
- name: ls build
76+
run: ls -lh build
77+
78+
- name: Publish release
79+
if: ${{ !github.event.inputs.dry_run && !github.event.inputs.snapshot }}
80+
uses: ncipollo/release-action@v1
81+
with:
82+
artifacts: "build/tunneld"
83+
body: "Docker image: `${{ env.docker_image_tag }}`"
84+
token: ${{ secrets.GITHUB_TOKEN }}
85+
86+
- name: Upload artifacts to actions (if dry-run or snapshot)
87+
if: ${{ github.event.inputs.dry_run || github.event.inputs.snapshot }}
88+
uses: actions/upload-artifact@v2
89+
with:
90+
name: release-artifacts
91+
path: |
92+
./build/tunneld
93+
retention-days: 7

.github/workflows/wgtunnel.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: wgtunnel
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
permissions:
11+
actions: none
12+
checks: none
13+
contents: read
14+
deployments: none
15+
issues: none
16+
packages: none
17+
pull-requests: none
18+
repository-projects: none
19+
security-events: none
20+
statuses: none
21+
22+
# Cancel in-progress runs for pull requests when developers push additional
23+
# changes.
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
27+
28+
jobs:
29+
fmt:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v2
34+
- name: Setup Go
35+
uses: actions/setup-go@v3
36+
with:
37+
go-version: "~1.19"
38+
- name: Check for unstaged files
39+
run: ./scripts/check_unstaged.sh
40+
41+
lint:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v2
46+
- name: Setup Go
47+
uses: actions/setup-go@v3
48+
with:
49+
go-version: "~1.19"
50+
- name: golangci-lint
51+
uses: golangci/golangci-lint-action@v3.2.0
52+
with:
53+
version: v1.48.0
54+
55+
test:
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Checkout
59+
uses: actions/checkout@v2
60+
- name: Setup Go
61+
uses: actions/setup-go@v3
62+
with:
63+
go-version: "~1.19"
64+
- name: Install gotestsum
65+
uses: jaxxstorm/action-install-gh-release@v1.7.1
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
with:
69+
repo: gotestyourself/gotestsum
70+
tag: v1.7.0
71+
- name: Test
72+
run: make test

.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Go workspace file
15+
go.work
16+
17+
# Build directory.
18+
build/

0 commit comments

Comments
 (0)