-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (46 loc) · 2.1 KB
/
build-binary.yml
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
name: Build Binary
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ '1.22.5' ]
os-flavor: [ 'linux' ]
architecture: [ 'amd64', 'arm', 'arm64' ]
path-to-build: [ './cmd/email-random' ]
steps:
- uses: actions/checkout@v4
# Caching is enabled by default when using setup-go
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
# You can test your matrix by printing the current Go version
- name: Display Go version
run: go version
- name: Get dependencies
run: go get ./...
- name: Print the list of files
run: ls -lsh .
- name: Print the branch/tag name and the commit hash
run: |
echo "Ref: ${{ github.ref }}; Commit: $GITHUB_SHA"
- name: Build binary for the required OS and architecture
run: |
OUTPUT_FILE_NAME="./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }}"
GOOS=${{ matrix.os-flavor }} GOARCH=${{ matrix.architecture }} \
-ldflags="-X \"github.com/icyflame/kindle-my-clippings-parser/internal/env.Version=${{ github.ref }} $GITHUB_SHA\"" \
go build $LDFLAGS -o $OUTPUT_FILE_NAME ${{ matrix.path-to-build }}
sha256sum $OUTPUT_FILE_NAME > $OUTPUT_FILE_NAME.checksum
- name: Print file output of the binary file that was built
run: |
file ./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }}
file ./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }}.checksum
- name: Upload binaries if a tag was pushed
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }}
./$(basename ${{ matrix.path-to-build }})-${{ matrix.os-flavor }}-${{ matrix.architecture }}.checksum