-
Notifications
You must be signed in to change notification settings - Fork 2
102 lines (98 loc) · 3.02 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
name: Release
on:
push:
branches:
- main
permissions:
contents: write # Enable the creation of GitHub releases
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Run tests
run: |
go test ./... -coverprofile coverage.out
build:
name: Build
runs-on: ubuntu-latest
needs:
- test
env:
CGO_ENABLED: 0
TAG: ${{ github.event.release.tag_name }}
steps:
- name: Checkout
uses: actions/checkout@v2
# Do not use fetch-depth 0 as suggested by Goreleaser,
# because we run with --snapshot and do not want issues with
# our non-SemVer tags
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Create artifacts
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# At this point we still don't have a tag. It is just as well, because
# we do not want a SemVer tag, and having a non SemVer tag would break
# GoReleaser (https://goreleaser.com/limitations/semver/).
- name: Upload amd64 assets
uses: actions/upload-artifact@v3
with:
name: cos-tool-amd64
path: dist/cos-tool_linux_amd64_v1/cos-tool
- name: Upload arm64 assets
uses: actions/upload-artifact@v3
with:
name: cos-tool-arm64
path: dist/cos-tool_linux_arm64/cos-tool
ghrelease:
name: Create GitHub Release
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y%m%d')"
- name: Checkout
uses: actions/checkout@v2
- name: Change perms on GITHUB_WORKSPACE
# Workaround for Git 2.34, see https://github.com/rickstaa/action-create-tag/issues/10
run: |
sudo chown -R root:root $GITHUB_WORKSPACE
sudo chmod -R 0777 $GITHUB_WORKSPACE
- name: Create release tag
uses: rickstaa/action-create-tag@v1
with:
tag: "rel-${{ steps.date.outputs.date }}"
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts/
- name: Prepare artifacts for release
run: |
mkdir -p artifacts/release
find artifacts -type f | awk -F/ '{ print $2 }' | xargs -I {} cp artifacts/{}/cos-tool artifacts/release/{}
- name: Create GitHub release
uses: ncipollo/release-action@v1
with:
name: "Release ${{ steps.date.outputs.date }}"
omitBody: true
artifacts: "artifacts/release/*"
tag: "rel-${{ steps.date.outputs.date }}"
token: ${{ secrets.GITHUB_TOKEN }}