-
Notifications
You must be signed in to change notification settings - Fork 3
108 lines (91 loc) · 2.88 KB
/
release.yaml
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
name: Release
on:
push:
tags:
- 'v*'
env:
artifacts_name: "building-artifacts"
jobs:
tests-and-linters:
uses: ./.github/workflows/build.yaml
prepare:
name: Prepare Variables
runs-on: [ubuntu-latest]
outputs:
release_version: ${{ steps.enver.outputs.release_version }}
steps:
- name: Set env
id: enver
run: |
# Release tag comes from the github reference.
RELEASE_TAG=$(echo ${GITHUB_REF} | sed -e 's!.*/!!')
# Ensure the release tag has expected format.
echo ${RELEASE_TAG} | grep -q '^v' || exit 1
# Release version is same as release tag without leading 'v'.
RELEASE_VERSION=$(echo ${GITHUB_REF} | sed -e 's!.*/v!!')
echo "release_version=${RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
build:
name: Build For Different Arch
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
needs: prepare
env:
release_version: ${{needs.prepare.outputs.release_version}}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: "Setup Go"
uses: actions/setup-go@v4
with:
go-version-file: './go.mod'
id: go
- name: Set env
run: |
# Set arch related variables
echo "goos=$(go env GOOS)" >> $GITHUB_ENV
echo "goarch=$(go env GOARCH)" >> $GITHUB_ENV
- name: Build on ${{runner.os}}
run: |
#Building for main platform
go build -o dkc-${{env.release_version}}-${{env.goos}}-${{env.goarch}} -ldflags="-X github.com/p2p-org/dkc/cmd.ReleaseVersion=${{env.release_version}}" .
tar zcf dkc-${{env.release_version}}-${{env.goos}}-${{env.goarch}}.tar.gz dkc-${{env.release_version}}-${{env.goos}}-${{env.goarch}}
shasum -a 256 dkc-${{env.release_version}}-${{env.goos}}-${{env.goarch}}.tar.gz >dkc-${{env.release_version}}-${{env.goos}}-${{env.goarch}}.sha256
- name: Save to artifacts
id: artifacts-save
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifacts_name }}
path: |
./dkc-**.tar.gz
./dkc-**.sha256
if-no-files-found: error
release:
name: Publish Release
runs-on: ubuntu-latest
needs:
- build
- prepare
env:
release_version: ${{needs.prepare.outputs.release_version}}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.artifacts_name }}
- name: Run Changelog CI
uses: saadmk11/[email protected]
with:
release_version: ${{ env.release_version }}
- name: Create Release
uses: softprops/action-gh-release@v1
with:
body_path: CHANGELOG.md
files: |
./dkc-**.tar.gz
./dkc-**.sha256
generate_release_notes: true
fail_on_unmatched_files: true