-
Notifications
You must be signed in to change notification settings - Fork 95
62 lines (58 loc) · 2.18 KB
/
release.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
name: "release"
on:
push:
tags: ['v*']
branches: [ master ]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v1
with:
go-version: 1.21.x
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Release
if: github.event.ref != 'refs/heads/master'
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build
if: github.event.ref == 'refs/heads/master'
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: build --snapshot --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Package
if: github.event.ref == 'refs/heads/master'
run: |
tar -zcf go-tpc_latest_linux_amd64.tar.gz -C dist/go-tpc_linux_amd64_v1 go-tpc
tar -zcf go-tpc_latest_linux_arm64.tar.gz -C dist/go-tpc_linux_arm64 go-tpc
tar -zcf go-tpc_latest_darwin_amd64.tar.gz -C dist/go-tpc_darwin_amd64_v1 go-tpc
tar -zcf go-tpc_latest_darwin_arm64.tar.gz -C dist/go-tpc_darwin_arm64 go-tpc
- name: Release latest build
uses: softprops/action-gh-release@v1
if: github.event.ref == 'refs/heads/master'
with:
name: Latest Build
tag_name: latest-${{ github.sha }}
files: |
*.tar.gz
- name: Clean legacy latest releases
uses: actions/github-script@v6
if: github.event.ref == 'refs/heads/master'
with:
script: |
const { owner, repo } = context.repo;
const releases = (await github.rest.repos.listReleases({ owner, repo })).data.filter(r => r.draft && r.tag_name.startsWith('latest'));
for (const r of releases) { await github.rest.repos.deleteRelease({ owner, repo, release_id: r.id }).catch(_ => {}); }
- name: Clean legacy latest tags
if: github.event.ref == 'refs/heads/master'
run: |
git tag -l | grep latest | grep -v latest-${{ github.sha }} | xargs -I{} git push -d origin {} || true