-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (102 loc) · 3.24 KB
/
release.yml
File metadata and controls
120 lines (102 loc) · 3.24 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
name: Build and Release WS Server (release.yml)
permissions:
contents: write
pull-requests: write
on:
workflow_dispatch:
inputs:
version:
description: 'Version tag for release (e.g., v1.0.0)'
required: true
default: 'v1.0.0'
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, openbsd]
goarch: [amd64]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.24
- name: Install dependencies
run: go mod tidy
- name: Build binary
run: |
output_name=wsserver-${{ matrix.goos }}-${{ matrix.goarch }}
if [ "${{ matrix.goos }}" = "windows" ]; then
output_name=${output_name}.exe
fi
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o $output_name main.go
- name: Zip binary
run: |
zip_name=wsserver-${{ matrix.goos }}-${{ matrix.goarch }}.zip
zip -j $zip_name wsserver-${{ matrix.goos }}-${{ matrix.goarch }}
- name: Generate checksum
id: checksum
run: |
zip_name=wsserver-${{ matrix.goos }}-${{ matrix.goarch }}.zip
sha=$(sha256sum $zip_name | awk '{print $1}')
echo "checksum=${zip_name}: ${sha}" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: wsserver-${{ matrix.goos }}-${{ matrix.goarch }}
path: wsserver-${{ matrix.goos }}-${{ matrix.goarch }}.zip
release:
permissions:
contents: write
pull-requests: write
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download artifacts
uses: actions/download-artifact@v8
with:
path: ./binaries
- name: Display structure of downloaded files
run: file ./binaries/*/*
- name: Create versioned GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ github.event.inputs.version }}
name: "WS Server ${{ github.event.inputs.version }}"
#body_path: ${{ github.workspace }}-CHANGELOG.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload versioned release assets
run: |
for f in ./binaries/*/*.zip; do
gh release upload ${{ github.event.inputs.version }} "$f" --clobber
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docker:
permissions:
contents: read
pull-requests: read
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push
uses: docker/build-push-action@v7
with:
file: ./.github/Dockerfile.buildx
context: .
push: true
tags: echothrust/wsserver:latest