-
Notifications
You must be signed in to change notification settings - Fork 39
125 lines (111 loc) · 3.21 KB
/
Copy pathrelease.yml
File metadata and controls
125 lines (111 loc) · 3.21 KB
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
# Use https://app.stepsecurity.io/ to improve workflow security
name: Create Release
on:
push:
tags: [ "v*.*.*" ]
permissions:
contents: read
jobs:
testing:
name: Testing
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Set up Go 1.x
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ^1.14
cache: false
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Check
run: make check
create_release:
permissions:
contents: write
name: Create Release
needs: [testing]
runs-on: ubuntu-latest
steps:
- name: Ensure GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
REPO: ${{ github.repository }}
run: |
set -euo pipefail
if gh release view "$TAG" --repo "$REPO" >/dev/null 2>&1; then
echo "Release $TAG already exists — reusing"
else
gh release create "$TAG" \
--repo "$REPO" \
--title "Release $TAG" \
--prerelease
fi
publish:
permissions:
contents: write
name: Publish
needs: [testing, create_release]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Set up Go 1.x
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ^1.14
cache: false
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Distribute
run: make dist
- name: Upload release asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.ref_name }}
REPO: ${{ github.repository }}
shell: bash
run: |
set -euo pipefail
if [ "$RUNNER_OS" = "Linux" ]; then
asset=./bin/paygate-linux-amd64
elif [ "$RUNNER_OS" = "macOS" ]; then
asset=./bin/paygate-darwin-amd64
else
asset=./bin/paygate.exe
fi
gh release upload "$TAG" "$asset" --repo "$REPO" --clobber
docker:
name: Docker
needs: [testing, create_release]
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ^1.14
cache: false
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Docker
run: make docker
- name: Docker Push
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
make release-push