-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (140 loc) · 4.52 KB
/
release.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
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
name: Release
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
PRODUCT: screenshot
jobs:
build:
name: Build
strategy:
matrix:
os: [ linux, windows, darwin ]
arch: [ amd64, 386 ]
include:
- os: linux
arch: arm64
- os: darwin
arch: arm64
exclude:
- os: darwin
arch: 386
fail-fast: false
runs-on: ubuntu-latest
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
GOARM: ${{ matrix.arm }}
GOMIPS: ${{ matrix.mips }}
GOMIPS64: ${{ matrix.mips64 }}
GOMIPSLE: ${{ matrix.mipsle }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: List checked-out code
run: ls -al
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.17
- name: Build fat binary
id: builder
run: |
ARGS="${GOOS}-${GOARCH}"
if [[ -n "${GOARM}" ]]; then
ARGS="${ARGS}v${GOARM}"
elif [[ -n "${GOMIPS}" ]]; then
ARGS="${ARGS}-${GOMIPS}"
elif [[ -n "${GOMIPS64}" ]]; then
ARGS="${ARGS}-${GOMIPS64}"
elif [[ -n "${GOMIPSLE}" ]]; then
ARGS="${ARGS}-${GOMIPSLE}"
fi
make ${ARGS}
echo "args=${ARGS}" >> $GITHUB_OUTPUT
- name: Archive binary
run: make TARGET=${{ steps.builder.outputs.args }} releases
- name: Upload archived binary
uses: actions/upload-artifact@v3
with:
name: ${{ env.PRODUCT }}
path: build/package/${{ env.PRODUCT }}*
release:
name: Release
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Check out code base
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.PRODUCT }}
path: ${{ env.PRODUCT }}
- name: Generate digests
working-directory: ${{ env.PRODUCT }}
id: digest
run: |
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
files="${{ env.PRODUCT }}*"
digests="$(find ${files} -type f -exec sha256sum {} +)"
delimiter="$(openssl rand -hex 8)"
echo "digests<<${delimiter}" >> $GITHUB_OUTPUT
echo "${digests}" >> $GITHUB_OUTPUT
echo "${delimiter}" >> $GITHUB_OUTPUT
- name: Generate Git log
run: |
git fetch origin +refs/tags/*:refs/tags/*
echo "Current Tag: ${GITHUB_REF}"
git checkout ${GITHUB_REF} -b release-log
GITVER=$(git describe --tags)
PREVVER=$(git describe --tags --abbrev=0 ${GITVER}~1)
git log --oneline ${PREVVER}..${GITVER} > gittaglogs.txt
MORE=$(echo "See more on [releases](https://github.com/${{ github.repository }}/releases)")
echo -e "*Release ${GITVER}* #screenshot\n" > release-note.md
cut -c9- gittaglogs.txt | sed -e 's/^/- /' | sed -e 's/\"/\\"/g' >> release-note.md
echo -e "\n${MORE}" | tee -a release-note.md gittaglogs.txt > /dev/null
# Append digests
echo '
**Digests in this release:**
```
${{ steps.digest.outputs.digests }}
```
' >> gittaglogs.txt
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: release-note
path: release-note.md
- name: Create Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
body_path: gittaglogs.txt
files: ${{ env.PRODUCT }}/*${{ env.PRODUCT }}*
prerelease: true
draft: false
notification:
name: Send Notification
runs-on: ubuntu-latest
needs: [release]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: release-note
path: .
- name: Send release note to Telegram channel
continue-on-error: true
run: |
TEXT="$(cat release-note.md)"
echo -e "${TEXT}"
curl --silent --output /dev/null --show-error --fail -X POST \
-H 'Content-Type: application/json' \
-d '{"chat_id": "${{ secrets.TELEGRAM_TO }}", "text": "'"${TEXT}"'", "parse_mode": "markdown"}' \
"https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage"