forked from dim13/hashcolor
-
Notifications
You must be signed in to change notification settings - Fork 1
103 lines (92 loc) · 3.39 KB
/
release.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
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
name: Release
on:
push:
tags: [ "v*" ]
jobs:
create:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Hashcolor ${{ github.ref }}
draft: true
prerelease: false
build:
name: Build Release binaries
runs-on: ubuntu-latest
needs: create
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Set up Go 1.x
id: go
uses: actions/setup-go@v2
with:
go-version: ^1.22
- name: Get dependencies
run: |
go get -v -t -d ./...
go mod download
go mod verify
- name: Build Golang binaries (${{ matrix.goos }}/${{ matrix.goarch }})
id: build_binary
env:
CGO_ENABLED: 0
GOOS: "${{ matrix.goos }}"
GOARCH: "${{ matrix.goarch }}"
run: |
go build -ldflags "-s -w -X main.Version=${{ steps.get_version.outputs.VERSION }}" \
-trimpath -o ./hashcolor \
./cmd/hashcolor/main.go
- name: Package (${{ matrix.goos }}/${{ matrix.goarch }})
env:
CGO_ENABLED: 0
GOOS: "${{ matrix.goos }}"
GOARCH: "${{ matrix.goarch }}"
VERSION: "${{ steps.get_version.outputs.VERSION }}"
run: |
mkdir -p "./build/hashcolor-${VERSION}"
cp -av --target-directory="./build/hashcolor-${VERSION}" \
./examples ./hashcolor ./LICENSE ./README.md
cd "./build/hashcolor-${VERSION}"
find . -type f -exec sha256sum "{}" + > checksums.lst
cd ..
tar cvzf "./hashcolor-${VERSION}-${GOOS}-${GOARCH}.tar.gz" \
"./hashcolor-${VERSION}"
sha256sum "./hashcolor-${VERSION}-${GOOS}-${GOARCH}.tar.gz" > \
"./hashcolor-${VERSION}-${GOOS}-${GOARCH}.tar.gz.sha256"
- name: Upload Release Tarball (${{ matrix.goos }}/${{ matrix.goarch }})
id: upload-release-tarball
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create.outputs.upload_url }}
asset_path: ./build/hashcolor-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
asset_name: hashcolor-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
asset_content_type: application/gzip
- name: Upload Release Digest (${{ matrix.goos }}/${{ matrix.goarch }})
id: upload-release-digest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create.outputs.upload_url }}
asset_path: ./build/hashcolor-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz.sha256
asset_name: hashcolor-${{ steps.get_version.outputs.VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz.sha256
asset_content_type: text/plain