-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (83 loc) · 2.84 KB
/
integration.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
name: Integration Pipeline
on:
push:
tags:
- "v*"
branches:
- '**'
jobs:
configure:
name: Preliminary configuration
runs-on: ubuntu-latest
outputs:
commit-ref: ${{ steps.configure.outputs.commit-ref }}
repo-name: ${{ steps.configure.outputs.repo-name }}
steps:
- name: Get the version
id: get_version
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
if: startsWith(github.ref, 'refs/tags/v')
- name: Configure
id: configure
run: |
if [ "${{ steps.get_version.outputs.VERSION }}" != "" ]; then
echo "commit-ref=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_OUTPUT
else
echo "commit-ref=${{ github.sha }}" >> $GITHUB_OUTPUT
fi
echo "repo-name=${{ github.repository }}" >> $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: [configure]
strategy:
matrix:
goos: [linux, darwin]
goarch: [arm64, amd64]
steps:
- uses: actions/checkout@v3
with:
ref: "${{ needs.configure.outputs.commit-ref }}"
repository: "${{ needs.configure.outputs.repo-name }}"
persist-credentials: false
- name: Build
run: |
go build -ldflags="-s -w -X 'main.version=${VERSION}'" -o gowatch-${{ matrix.goos }}-${{ matrix.goarch }} cmd/main.go
env:
CGO_ENABLED: 0
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
VERSION: ${{ needs.configure.outputs.commit-ref }}
- name: Create Archives
run: |
cp gowatch-${{ matrix.goos }}-${{ matrix.goarch }} gowatch
tar -czvf gowatch-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz gowatch LICENSE
- name: Upload
uses: actions/upload-artifact@v3
with:
name: gowatch-${{ matrix.goos }}-${{ matrix.goarch }}
path: ./gowatch-${{ matrix.goos }}-${{ matrix.goarch }}
retention-days: 1
release:
runs-on: ubuntu-latest
needs: [build, configure]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# The changelog generation requires the entire history
fetch-depth: 0
ref: "${{ needs.configure.outputs.commit-ref }}"
repository: "${{ needs.configure.outputs.repo-name }}"
persist-credentials: false
- uses: actions/download-artifact@v3
with:
path: ./gowatch/
- uses: ncipollo/release-action@v1
with:
artifacts: "./gowatch/**/*"
token: ${{ secrets.CI_TOKEN }}
allowUpdates: true
tag: ${{ needs.configure.outputs.commit-ref }}
name: ${{ needs.configure.outputs.commit-ref }}
prerelease: false