-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (169 loc) · 5.68 KB
/
release.yml
File metadata and controls
199 lines (169 loc) · 5.68 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Release
on:
workflow_dispatch:
inputs:
branch:
description: "The branch that will be built"
required: true
version:
description: "The version to release (must be prefixed with 'v')"
required: true
env:
VERSION: ${{ github.event.inputs.version }}
GH_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
jobs:
goreleaser:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
- name: Unshallow
run: git fetch
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
# - name: Hook private repo
# run: git config --global url."https://${{ secrets.GORELEASER_GITHUB_TOKEN }}:x-oauth-basic@github.com".insteadOf "https://github.com"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --snapshot --rm-dist --skip-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Move build artifacts
run: |
mkdir ~/artifacts
mv $GITHUB_WORKSPACE/dist/remote-shell_linux_amd64.tar.gz ~/artifacts/linux.tar.gz
mv $GITHUB_WORKSPACE/dist/remote-shell_darwin_amd64.zip ~/artifacts/darwin.zip
- name: List Build Artifacts
run: ls -l ~/artifacts
- name: Save Linux Build Artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact-linux
path: ~/artifacts/linux.tar.gz
if-no-files-found: error
- name: Save MacOS Build Artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact-darwin
path: ~/artifacts/darwin.zip
if-no-files-found: error
create_release_tag:
name: Tag Release
needs: [goreleaser]
runs-on: ubuntu-latest
steps:
- name: Trim asset version prefix and Validate
run: |-
echo $VERSION
trim=${VERSION#"v"}
echo $trim
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
echo "Version OK: $trim"
else
echo "Invalid version: $trim"
exit 1
fi
echo "VERSION=${trim}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}
- name: Unshallow
run: git fetch --prune --unshallow
- name: Tag Release
run: |
git config user.name "Cloud87 GitHub Actions Bot"
git config user.email noreply@github.com
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}
ensure_branch_in_homebrew:
name: Ensure branch exists in homebrew-tap
needs: [create_release_tag]
runs-on: ubuntu-latest
steps:
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@v3
with:
repository: webdestroya/homebrew-tap
token: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
ref: main
- name: Delete base branch if exists
if: steps.semver_parser.outputs.prerelease == ''
run: |
git fetch --all
git push origin --delete bump-brew
git push origin --delete $VERSION
continue-on-error: true
- name: Create base branch
if: steps.semver_parser.outputs.prerelease == ''
run: |
git checkout -b bump-brew
git push --set-upstream origin bump-brew
create_release:
name: Release
needs: [create_release_tag, ensure_branch_in_homebrew]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.version }}
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
create_pr_in_homebrew:
name: Create PR in homebrew-tap
needs: [ensure_branch_in_homebrew, create_release]
runs-on: ubuntu-latest
env:
Version: ${{ github.event.inputs.version }}
steps:
- name: Parse semver string
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
with:
input_string: ${{ github.event.inputs.version }}
- name: Checkout
if: steps.semver_parser.outputs.prerelease == ''
uses: actions/checkout@v3
with:
repository: webdestroya/homebrew-tap
token: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
ref: main
- name: Create a new branch off the base branch
if: steps.semver_parser.outputs.prerelease == ''
run: |
git fetch --all
git checkout bump-brew
git checkout -b rshell/$VERSION
git push --set-upstream origin rshell/$VERSION
- name: Close pull request if already exists
if: steps.semver_parser.outputs.prerelease == ''
run: |
gh pr close rshell/$VERSION
continue-on-error: true
- name: Create pull request
if: steps.semver_parser.outputs.prerelease == ''
run: |
gh pr create --base main --head rshell/$VERSION --title "[RShell] $Version" --body "Update formula"