-
Notifications
You must be signed in to change notification settings - Fork 2
157 lines (137 loc) · 4.77 KB
/
ci.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: ci
on:
push:
branches: [ main ]
tags:
'v*'
pull_request:
branches: [ main ]
jobs:
# This is a super hacky way to get this into a place that can actually be
# used by downstream jobs because YAML values don't allow shell
# interpolation, only github expression interpolation
store-sha8:
name: Store The Short Hash
runs-on: ubuntu-latest
outputs:
sha8: ${{ steps.calc-short.outputs.sha8 }}
steps:
- name: Calculate Short Hash
id: calc-short
run: echo "::set-output name=sha8::${GITHUB_SHA::8}"
build:
name: Build
needs: [store-sha8]
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
go-version: ["1.20"]
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Set artifact name
run: echo "name=aterm-${{ needs.store-sha8.outputs.sha8 }}-$(uname -s | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Install go tools
run: |
go install golang.org/x/lint/golint@latest
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Build Repo
run: go build -v ./...
- name: gofmt
run: |
GOFMTOUT=$(gofmt -l .)
if [[ ! -z "${GOFMTOUT}" ]]; then
echo "FATAL: gofmt violation(s), please fix"
echo $GOFMTOUT
exit -1
fi
- name: go vet
run: go vet ./...
- name: golint
run: golint ./...
- name: Test
run: go test -v ./...
- name: Build Executable
run: |
go build -o cmd/aterm/aterm -ldflags "-X github.com/jrozner/go-info.version=${GITHUB_REF} -X github.com/jrozner/go-info.commitHash=${GITHUB_SHA} -X github.com/jrozner/go-info.buildDate=$(date -u +'%Y-%m-%dT%H:%M:%SZ') -X github.com/theparanoids/aterm/cmd/aterm/config.codeRepoRaw=${GITHUB_REPOSITORY}" cmd/aterm/*.go
- name: package
run: |
mkdir dist
cp cmd/aterm/aterm dist/
cp cmd/aterm/example.config.yaml dist/config.yaml
cp LICENSE dist/LICENSE
cp README.md dist/README.md
- name: Import Code-Signing Certificates
if: |
matrix.os == 'macos-latest' &&
(contains(github.ref, 'tags/v') || github.ref == 'refs/heads/main' || contains(github.ref, 'refs/heads/release'))
uses: Apple-Actions/[email protected]
with:
p12-file-base64: ${{ secrets.MACOS_CERT }}
p12-password: ${{ secrets.MACOS_PASS }}
- name: Install gon via HomeBrew and Notarize (mac)
if: |
matrix.os == 'macos-latest' &&
(contains(github.ref, 'tags/v') || github.ref == 'refs/heads/main' || contains(github.ref, 'refs/heads/release'))
env:
GON_CONF: ${{ secrets.GON_CONF }}
run: |
brew tap mitchellh/gon
brew install mitchellh/gon/gon
echo "$GON_CONF" | base64 -D -i - > notarize.json
gon notarize.json
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.name }}
path: dist
release:
name: Create GitHub Release
if: contains(github.ref, 'tags/v')
needs: [store-sha8, build]
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
steps:
- name: Create Release
id: create-release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
publish:
if: contains(github.ref, 'tags/v')
needs: [store-sha8, build, release]
runs-on: ubuntu-latest
strategy:
matrix:
platform: [darwin, linux]
steps:
- name: Set Version
run: echo "version=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV
- name: Download Previous Artifacts
uses: actions/download-artifact@v4
with:
name: aterm-${{ needs.store-sha8.outputs.sha8 }}-${{ matrix.platform }}
path: aterm-${{ env.version }}-${{ matrix.platform }}
- name: Produce Zip
run: zip -r aterm-${{ env.version }}-${{ matrix.platform }}.zip aterm-${{ env.version }}-${{ matrix.platform }}
- name: Upload Release Asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: aterm-${{ env.version }}-${{ matrix.platform }}.zip
asset_name: aterm-${{ env.version }}-${{ matrix.platform }}.zip
asset_content_type: application/zip