-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (93 loc) · 2.77 KB
/
go.yml
File metadata and controls
116 lines (93 loc) · 2.77 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
name: Build and Release Go Project
on:
push:
branches:
- main
permissions:
contents: write
jobs:
version:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Generate Release Tag
id: generate_tag
run: |
VERSION_TAG="v$(date +'%Y%m%d-%H%M%S')-$(git rev-parse --short HEAD)"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
echo "Generated tag: $VERSION_TAG"
echo "$VERSION_TAG" > VERSION
- name: Upload VERSION Artifact
uses: actions/upload-artifact@v4
with:
name: VERSION
path: VERSION
build:
needs: version
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Download VERSION Tag
uses: actions/download-artifact@v4
with:
name: VERSION
- name: Set TAG_NAME environment variable
run: |
TAG_NAME=$(cat VERSION)
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "Using tag: $TAG_NAME"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install dependencies
run: go mod tidy
- name: Build the Go application
run: |
GOARCH=${{ matrix.arch }} go build -ldflags "-X main.version=${{ env.TAG_NAME }}" -o docker-compose-exec-${{ matrix.arch }}
- name: Generate SHA256
run: sha256sum docker-compose-exec-${{ matrix.arch }} > docker-compose-exec-${{ matrix.arch }}.sha256
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: docker-compose-exec-${{ matrix.arch }}
path: |
docker-compose-exec-${{ matrix.arch }}
docker-compose-exec-${{ matrix.arch }}.sha256
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: docker-compose-exec-amd64
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: docker-compose-exec-arm64
- name: Download VERSION Tag
uses: actions/download-artifact@v4
with:
name: VERSION
- name: Set TAG_NAME environment variable
run: |
TAG_NAME=$(cat VERSION)
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
echo "Using tag: $TAG_NAME"
- name: Create Release
uses: ncipollo/release-action@v1
with:
artifacts: "docker-compose-exec-*"
token: ${{ secrets.PAT_TOKEN }}
tag: ${{ env.TAG_NAME }}
name: Release ${{ env.TAG_NAME }}
commit: ${{ github.sha }}
skipIfReleaseExists: true