-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (105 loc) · 3.35 KB
/
cicd.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
on: [push]
permissions:
contents: write
pull-requests: write
jobs:
test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.19'
- run: go test ./...
env:
TZ: America/Los_Angeles
build:
strategy:
matrix:
cur:
- {GOOS: linux, GOARCH: amd64, outfile: leatherman.xz}
- {GOOS: linux, GOARCH: arm, outfile: leatherman.arm.xz}
- {GOOS: darwin, GOARCH: amd64, outfile: leatherman.mac.xz}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.19'
- run: go build -o leatherman
env:
GOOS: ${{ matrix.cur.GOOS }}
GOARCH: ${{ matrix.cur.GOARCH }}
- run: xz --stdout leatherman > ${{ matrix.cur.outfile}}
- uses: actions/upload-artifact@master
with:
name: ${{ matrix.cur.outfile }}
path: ${{ matrix.cur.outfile }}
build-windows:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.19'
- run: go build -o leatherman.exe
env:
GOOS: windows
GOARCH: amd64
- run: zip leatherman-windows.zip leatherman.exe
- uses: actions/upload-artifact@master
with:
name: leatherman-windows.zip
path: leatherman-windows.zip
dependabot:
runs-on: ubuntu-latest
# Only run this job for dependabot PRs
if: ${{ github.actor == 'dependabot[bot]' }}
# Only run if the required checks pass
needs: [test, build, build-windows]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Auto-merge Dependabot PRs
# Find the PR number based on the current branch name, and squash merge based on this number
run: 'PR_NUM="$(gh pr list | grep $(git branch --show-current) | cut -f1)"; gh pr merge --auto --squash $PR_NUM'
env:
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
release:
needs: [test, build, build-windows]
runs-on: ubuntu-20.04
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url}}
steps:
- uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: untagged-${{ github.sha }}
- id: create_release
uses: actions/create-release@v1
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: untagged-${{ github.sha }}
release_name: Release ${{ github.sha }}
upload:
needs: [release]
strategy:
matrix:
file: ['leatherman.xz', 'leatherman-windows.zip', 'leatherman.arm.xz', 'leatherman.mac.xz']
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@master
with:
name: ${{ matrix.file }}
path: .
- uses: actions/upload-release-asset@v1
if: github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./${{ matrix.file }}
asset_name: ${{ matrix.file }}
asset_content_type: application/x-xz