1313 IMAGE_NAME : rajsinghtech/tsflow
1414
1515jobs :
16- test :
17- runs-on : ubuntu-latest
18- steps :
19- - uses : actions/checkout@v4
20-
21- - name : Set up Go
22- uses : actions/setup-go@v4
23- with :
24- go-version : ' 1.21'
25-
26- - name : Cache Go modules
27- uses : actions/cache@v4
28- with :
29- path : ~/go/pkg/mod
30- key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
31- restore-keys : |
32- ${{ runner.os }}-go-
33-
34- - name : Download dependencies
35- run : go mod download
36-
37- - name : Run tests
38- run : go test -v ./...
39-
40- - name : Run go vet
41- run : go vet ./...
42-
4316 build :
44- needs : test
4517 runs-on : ubuntu-latest
4618 permissions :
47- contents : read
19+ contents : write
4820 packages : write
4921
5022 steps :
@@ -55,130 +27,89 @@ jobs:
5527 uses : actions/setup-go@v4
5628 with :
5729 go-version : ' 1.21'
30+ cache : true
5831
59- - name : Cache Go modules
60- uses : actions/cache@v4
61- with :
62- path : ~/go/pkg/mod
63- key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
64- restore-keys : |
65- ${{ runner.os }}-go-
66-
6732 - name : Download dependencies
6833 run : go mod download
69-
70- - name : Build binaries
34+
35+ - name : Run tests
36+ run : |
37+ go test -v ./...
38+ go vet ./...
39+
40+ - name : Build binary
41+ run : |
42+ go build -ldflags="-w -s" -o tsflow .
43+ chmod +x tsflow
44+
45+ - name : Build multi-platform binaries
46+ if : github.event_name == 'release'
7147 run : |
72- # Build for multiple platforms
7348 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o tsflow-linux-amd64 .
7449 GOOS=linux GOARCH=arm64 go build -ldflags="-w -s" -o tsflow-linux-arm64 .
7550 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o tsflow-darwin-amd64 .
7651 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o tsflow-darwin-arm64 .
7752 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o tsflow-windows-amd64.exe .
78-
79- # Make them executable
8053 chmod +x tsflow-*
81-
54+
55+ - name : Set up Docker Buildx
56+ if : github.event_name != 'pull_request'
57+ uses : docker/setup-buildx-action@v3
58+
8259 - name : Log in to Container Registry
8360 if : github.event_name != 'pull_request'
8461 uses : docker/login-action@v3
8562 with :
8663 registry : ${{ env.REGISTRY }}
8764 username : ${{ github.actor }}
88- password : ${{ secrets.GH_TOKEN }}
89-
90- - name : Extract metadata
91- id : meta
92- uses : docker/metadata-action@v5
93- with :
94- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
95- tags : |
96- type=ref,event=branch
97- type=ref,event=pr
98- type=semver,pattern={{version}}
99- type=semver,pattern={{major}}.{{minor}}
100- type=raw,value=latest,enable={{is_default_branch}}
101-
102- - name : Set up Docker Buildx
103- uses : docker/setup-buildx-action@v3
104-
65+ password : ${{ secrets.GITHUB_TOKEN }}
66+
10567 - name : Build and push Docker image
10668 if : github.event_name != 'pull_request'
10769 uses : docker/build-push-action@v5
10870 with :
10971 context : .
11072 platforms : linux/amd64,linux/arm64
11173 push : true
112- tags : ${{ steps.meta.outputs.tags }}
113- labels : ${{ steps.meta.outputs.labels }}
74+ tags : |
75+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
76+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
11477 cache-from : type=gha
11578 cache-to : type=gha,mode=max
116-
117- - name : Upload binaries as artifacts
118- uses : actions/upload-artifact@v4
119- with :
120- name : tsflow-binaries
121- path : |
122- tsflow-*
123- retention-days : 30
124-
125- release :
126- if : github.event_name == 'release'
127- needs : build
128- runs-on : ubuntu-latest
129- permissions :
130- contents : write
131-
132- steps :
133- - name : Checkout repository
134- uses : actions/checkout@v4
13579
136- - name : Download artifacts
137- uses : actions/download-artifact@v4
138- with :
139- name : tsflow-binaries
140- path : ./binaries
141-
14280 - name : Create release archives
81+ if : github.event_name == 'release'
14382 run : |
144- cd binaries
145- # Create archives for each platform
14683 tar -czf tsflow-linux-amd64.tar.gz tsflow-linux-amd64
14784 tar -czf tsflow-linux-arm64.tar.gz tsflow-linux-arm64
14885 tar -czf tsflow-darwin-amd64.tar.gz tsflow-darwin-amd64
14986 tar -czf tsflow-darwin-arm64.tar.gz tsflow-darwin-arm64
15087 zip tsflow-windows-amd64.zip tsflow-windows-amd64.exe
151-
152- # Create checksums
15388 sha256sum *.tar.gz *.zip > checksums.txt
154-
89+
15590 - name : Upload release assets
91+ if : github.event_name == 'release'
15692 uses : softprops/action-gh-release@v1
15793 with :
15894 files : |
159- binaries/ *.tar.gz
160- binaries/ *.zip
161- binaries/ checksums.txt
95+ *.tar.gz
96+ *.zip
97+ checksums.txt
16298 body : |
16399 ## TSFlow ${{ github.ref_name }}
164100
165- ### Installation
166-
167- #### Docker
101+ ### Docker Installation
168102 ```bash
169- docker pull ghcr.io/rajsinghtech/tsflow:${{ github.ref_name }}
103+ docker pull ghcr.io/rajsinghtech/tsflow:latest
170104 docker run -p 8080:8080 \
171105 -e TAILSCALE_ACCESS_TOKEN="your-token" \
172106 -e TAILSCALE_TAILNET="your-tailnet" \
173- ghcr.io/rajsinghtech/tsflow:${{ github.ref_name }}
107+ ghcr.io/rajsinghtech/tsflow:latest
174108 ```
175109
176- #### Binary Download
110+ ### Binary Installation
177111 Download the appropriate binary for your platform from the assets below.
178-
179- ### Checksums
180- Verify your download with the provided checksums.txt file.
181112 draft : false
182113 prerelease : false
183114 env :
184- GH_TOKEN : ${{ secrets.GH_TOKEN }}
115+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments