-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (140 loc) · 6.09 KB
/
Copy pathrelease.yml
File metadata and controls
165 lines (140 loc) · 6.09 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
---
name: release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build linux-amd64
run: GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version=${GITHUB_REF_NAME}" -o bin/linux-amd64/gitte .
- run: tar czf bin/gitte-linux-amd64.tar.gz -C bin/linux-amd64 gitte
- name: Build linux-arm64
run: GOOS=linux GOARCH=arm64 go build -ldflags "-X main.version=${GITHUB_REF_NAME}" -o bin/linux-arm64/gitte .
- run: tar czf bin/gitte-linux-arm64.tar.gz -C bin/linux-arm64 gitte
- name: Build windows-amd64
run: GOOS=windows GOARCH=amd64 go build -ldflags "-X main.version=${GITHUB_REF_NAME}" -o bin/windows-amd64/gitte.exe .
- run: (cd bin/windows-amd64 && zip ../gitte-windows-amd64.zip gitte.exe)
- name: Build darwin-amd64
run: GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version=${GITHUB_REF_NAME}" -o bin/darwin-amd64/gitte .
- run: tar czf bin/gitte-darwin-amd64.tar.gz -C bin/darwin-amd64 gitte
- name: Build darwin-arm64
run: GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.version=${GITHUB_REF_NAME}" -o bin/darwin-arm64/gitte .
- run: tar czf bin/gitte-darwin-arm64.tar.gz -C bin/darwin-arm64 gitte
- name: Create GitHub Release
if: github.ref_type == 'tag'
run: |
gh release create "${GITHUB_REF_NAME}" bin/gitte-*.tar.gz bin/gitte-*.zip --generate-notes ||
gh release upload "${GITHUB_REF_NAME}" bin/gitte-*.tar.gz bin/gitte-*.zip --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to APT (gitte-ppa.cego.dk)
if: github.ref_type == 'tag'
continue-on-error: true
env:
VERSION: ${{ github.ref_name }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PPA_SSH_KEY: ${{ secrets.PPA_SSH_KEY }}
run: |
sudo apt-get install -y dpkg-dev apt-utils
echo "${GPG_PRIVATE_KEY}" | gpg --batch --import
DESCRIPTION="Developer environment orchestration tool"
mkdir -p ppa
for ARCH in amd64 arm64; do
SRCBIN="bin/linux-${ARCH}/gitte"
PKGDIR="pkg/gitte_${VERSION}_${ARCH}"
mkdir -p "${PKGDIR}/DEBIAN" "${PKGDIR}/usr/local/bin"
cat > "${PKGDIR}/DEBIAN/control" << EOF
Name: gitte
Package: gitte
Version: ${VERSION}
Architecture: ${ARCH}
Author: Cego A/S <noc+gitte@cego.dk>
Maintainer: Cego A/S <noc+gitte@cego.dk>
Description: ${DESCRIPTION}
Homepage: https://github.com/cego/gitte
Website: https://github.com/cego/gitte
EOF
cp "${SRCBIN}" "${PKGDIR}/usr/local/bin/"
dpkg-deb --root-owner-group --build "${PKGDIR}" ppa/
done
(cd ppa && dpkg-scanpackages --multiversion . > Packages)
(cd ppa && gzip -k -f Packages)
(cd ppa && apt-ftparchive release . > Release)
(cd ppa && gpg --default-key "noc+gitte@cego.dk" -abs -o - Release > Release.gpg)
(cd ppa && gpg --default-key "noc+gitte@cego.dk" --clearsign -o - Release > InRelease)
echo "${PPA_SSH_KEY}" > /tmp/ppa_key
chmod 600 /tmp/ppa_key
rsync -az -e "ssh -i /tmp/ppa_key -o StrictHostKeyChecking=no" \
ppa/ deploy@gitte-ppa.cego.dk:/var/www/ppa/
rm /tmp/ppa_key
- name: Generate app token for formula push
if: github.ref_type == 'tag'
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
repositories: gitte
- name: Update Homebrew formula
if: github.ref_type == 'tag'
env:
VERSION: ${{ github.ref_name }}
APP_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
SHA_DARWIN_AMD64=$(sha256sum bin/gitte-darwin-amd64.tar.gz | awk '{print $1}')
SHA_DARWIN_ARM64=$(sha256sum bin/gitte-darwin-arm64.tar.gz | awk '{print $1}')
SHA_LINUX_AMD64=$(sha256sum bin/gitte-linux-amd64.tar.gz | awk '{print $1}')
SHA_LINUX_ARM64=$(sha256sum bin/gitte-linux-arm64.tar.gz | awk '{print $1}')
git config user.email "noc+gitte@cego.dk"
git config user.name "CI"
git remote set-url origin "https://x-access-token:${APP_TOKEN}@github.com/cego/gitte"
git fetch origin main
git checkout main
mkdir -p Formula
cat > Formula/gitte.rb << EOF
class Gitte < Formula
desc "Developer environment orchestration tool"
homepage "https://github.com/cego/gitte"
version "${VERSION}"
license "MIT"
on_macos do
if Hardware::CPU.arm?
url "https://github.com/cego/gitte/releases/download/${VERSION}/gitte-darwin-arm64.tar.gz"
sha256 "${SHA_DARWIN_ARM64}"
else
url "https://github.com/cego/gitte/releases/download/${VERSION}/gitte-darwin-amd64.tar.gz"
sha256 "${SHA_DARWIN_AMD64}"
end
end
on_linux do
if Hardware::CPU.arm?
url "https://github.com/cego/gitte/releases/download/${VERSION}/gitte-linux-arm64.tar.gz"
sha256 "${SHA_LINUX_ARM64}"
else
url "https://github.com/cego/gitte/releases/download/${VERSION}/gitte-linux-amd64.tar.gz"
sha256 "${SHA_LINUX_AMD64}"
end
end
def install
bin.install "gitte"
end
test do
system "#{bin}/gitte", "--version"
end
end
EOF
git add Formula/gitte.rb
git commit -m "Update Homebrew formula for ${VERSION}"
git push origin main