-
Notifications
You must be signed in to change notification settings - Fork 5
190 lines (167 loc) · 6.02 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
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
name: Release
on:
release:
types: [created]
permissions:
contents: write
id-token: write
jobs:
update-version:
name: Update version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Update version
run: |
DATE=$(date -u +"%Y-%m-%d")
sed -i "s/const Version = \".*\"/const Version = \"${GITHUB_REF_NAME}\"/" pkg/version/version.go
sed -i "s/const Revision = \".*\"/const Revision = \"${GITHUB_SHA}\"/" pkg/version/version.go
sed -i "s/const Date = \".*\"/const Date = \"${DATE}\"/" pkg/version/version.go
sed -i "s/Standards-Version: \*.*\"/Standards-Version: \"${GITHUB_REF_NAME}\"/" build/debian/control
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add pkg/version/version.go
git commit -m "Update version to ${GITHUB_REF_NAME}"
git push origin main
goreleaser:
needs: update-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '>=1.20.0'
# - name: Create vendor archive
# run: |
# go mod vendor
# tar czf vendor.tar.gz vendor/
# rm -rf vendor
- name: Install Cosign
uses: sigstore/cosign-installer@v3.7.0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: v2.4.8
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_EXPERIMENTAL: 1
publish-aur:
needs: [goreleaser]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate PKGBUILD
run: |
# Remove 'v' prefix from version number for pkgver
VERSION="${GITHUB_REF_NAME}"
VERSION_NO_V=$(echo "$VERSION" | sed 's/^v//')
echo "Building package for version: $VERSION_NO_V"
cat > PKGBUILD << EOF
# Maintainer: Chris Watson <cawatson1993@gmail.com>
pkgname=goshot-bin
pkgver=${VERSION_NO_V}
pkgrel=1
pkgdesc="A powerful CLI tool and library for creating beautiful code screenshots with customizable window chrome, syntax highlighting, and backgrounds"
arch=('x86_64' 'aarch64')
url="https://github.com/watzon/goshot"
license=('MIT')
optdepends=(
'wl-clipboard: clipboard support for Wayland'
'xclip: clipboard support for X11'
)
provides=('goshot')
conflicts=('goshot')
source_x86_64=("goshot_Linux_x86_64.tar.gz::https://github.com/watzon/goshot/releases/download/v\${pkgver}/goshot_Linux_x86_64.tar.gz")
source_aarch64=("goshot_Linux_arm64.tar.gz::https://github.com/watzon/goshot/releases/download/v\${pkgver}/goshot_Linux_arm64.tar.gz")
sha256sums_x86_64=('SKIP')
sha256sums_aarch64=('SKIP')
package() {
cd "\$srcdir"
install -Dm755 goshot "\$pkgdir/usr/bin/goshot"
install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
}
EOF
- name: Publish AUR package
uses: KSXGitHub/github-actions-deploy-aur@v3.0.1
with:
pkgname: goshot-bin
pkgbuild: ./PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to version ${GITHUB_REF#refs/tags/v}"
# ppa:
# name: Build and publish to PPA
# needs: [goreleaser]
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Setup Go
# uses: actions/setup-go@v4
# with:
# go-version: stable
# - name: Create vendor archive
# run: |
# go mod vendor
# tar czf vendor.tar.gz vendor/
# rm -rf vendor
# - name: Download release assets
# run: |
# mkdir -p build/debian
# curl -sL https://github.com/watzon/goshot/releases/download/${GITHUB_REF_NAME}/goshot_Linux_x86_64.tar.gz | tar xzf - -C build/debian
# - name: Import GPG
# uses: crazy-max/ghaction-import-gpg@v3.1.0
# with:
# gpg-private-key: ${{ secrets.LAUNCHPAD_GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.LAUNCHPAD_GPG_PASSPHRASE }}
# - name: Install dependencies
# run: |
# sudo apt-get update
# sudo apt-get install -y devscripts debhelper-compat dput
# - name: Prepare package
# env:
# DEBEMAIL: "cawatson1993@gmail.com"
# DEBFULLNAME: "Chris Watson"
# run: |
# VERSION=${GITHUB_REF#refs/tags/v}
# # Copy debian directory to the right place and create orig tarball
# cp -r build/debian debian
# cp vendor.tar.gz .
# mv .github ..
# tar cfv ../goshot_${VERSION}.orig.tar .
# xz -9 ../goshot_${VERSION}.orig.tar
# mv ../.github .
# # Update changelog
# dch -v ${VERSION}-1 --distribution jammy "New upstream release"
# - name: Build source package
# run: debuild -S -sa -d
# - name: Upload to PPA
# run: |
# cat > ~/.dput.cf << EOF
# [ppa]
# fqdn = ppa.launchpad.net
# method = ftp
# incoming = ~watzon/ubuntu/goshot
# login = anonymous
# allow_unsigned_uploads = no
# EOF
# dput ppa:watzon/goshot ../goshot_*_source.changes