Repository navigation
226 lines (213 loc) · 8.76 KB
/
Copy pathpackage-managers.yml
File metadata and controls
226 lines (213 loc) · 8.76 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Publishes each release to the package managers once the Release workflow has attached its
# files: a Homebrew tap, the AUR, Fedora COPR and winget. Every channel is its own job, skips
# itself when its secret is missing and never fails the others. Pre-releases are not published.
# Run it by hand with a tag to republish a release. See packaging/README.md.
#
# Repository secrets:
# HOMEBREW_TAP_DEPLOY_KEY - private half of an SSH deploy key with write access to
# opengeos/homebrew-rustgis
# AUR_SSH_PRIVATE_KEY - private SSH key of the AUR account that maintains rustgis-bin
# COPR_CONFIG - the copr-cli config block from https://copr.fedorainfracloud.org/api/
# (the token expires after 180 days)
# WINGET_TOKEN - classic token (public_repo) of the account owning the winget-pkgs fork
name: Package managers
on:
workflow_run:
workflows: [Release]
types: [completed]
workflow_dispatch:
inputs:
tag:
description: Release tag to publish (defaults to the latest release)
required: false
type: string
permissions:
contents: read
concurrency:
group: package-managers-${{ inputs.tag || github.event.workflow_run.head_branch || 'latest' }}
cancel-in-progress: false
jobs:
release:
name: Resolve the release
# A workflow_run fires for trial runs too; only a published release's build counts.
if: >-
github.repository == 'opengeos/RustGIS' &&
(github.event_name != 'workflow_run' ||
(github.event.workflow_run.event == 'release' &&
github.event.workflow_run.conclusion == 'success'))
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.release.outputs.tag }}
version: ${{ steps.release.outputs.version }}
date: ${{ steps.release.outputs.date }}
publish: ${{ steps.release.outputs.publish }}
steps:
- name: Resolve the release
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REQUESTED_TAG: ${{ inputs.tag }}
WORKFLOW_TAG: ${{ github.event.workflow_run.head_branch }}
run: |
tag="${REQUESTED_TAG:-${WORKFLOW_TAG:-}}"
if [ -z "$tag" ]; then
tag="$(gh api "repos/$GITHUB_REPOSITORY/releases/latest" --jq .tag_name)"
fi
json="$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$tag")"
version="${tag#v}"
publish=true
if [ "$(jq -r .prerelease <<< "$json")" = true ] || ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::notice::$tag is a pre-release: not published to package managers."
publish=false
fi
{
echo "tag=$tag"
echo "version=$version"
echo "date=$(jq -r .published_at <<< "$json" | cut -dT -f1)"
echo "publish=$publish"
} >> "$GITHUB_OUTPUT"
homebrew:
name: Homebrew tap
needs: release
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
continue-on-error: true
concurrency:
group: homebrew-tap
cancel-in-progress: false
env:
TAP_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
if: env.TAP_KEY != ''
with:
persist-credentials: false
- name: Update opengeos/homebrew-rustgis
if: env.TAP_KEY != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.release.outputs.tag }}
VERSION: ${{ needs.release.outputs.version }}
run: |
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern SHA256SUMS --dir "$RUNNER_TEMP"
eval "$(ssh-agent -s)"
ssh-add - <<< "$TAP_KEY"
git clone --depth 1 git@github.com:opengeos/homebrew-rustgis.git "$RUNNER_TEMP/tap"
packaging/homebrew/render.sh "$VERSION" "$RUNNER_TEMP/SHA256SUMS" "$RUNNER_TEMP/tap"
cd "$RUNNER_TEMP/tap"
git add Casks Formula
if git diff --cached --quiet; then
echo "The tap already has $VERSION."
exit 0
fi
git -c user.name="github-actions[bot]" -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
commit -m "rustgis $VERSION"
git push origin HEAD
aur:
name: AUR
needs: release
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
continue-on-error: true
concurrency:
group: aur
cancel-in-progress: false
env:
AUR_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
if: env.AUR_KEY != ''
with:
persist-credentials: false
- name: Render the PKGBUILD
if: env.AUR_KEY != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.release.outputs.tag }}
VERSION: ${{ needs.release.outputs.version }}
run: |
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --pattern SHA256SUMS --dir "$RUNNER_TEMP"
mkdir -p aur
packaging/aur/render.sh "$VERSION" "$RUNNER_TEMP/SHA256SUMS" > aur/PKGBUILD
cat aur/PKGBUILD
- name: Push rustgis-bin to the AUR
if: env.AUR_KEY != ''
# Pinned to a commit: this step receives the AUR key.
uses: KSXGitHub/github-actions-deploy-aur@084b0d9b15415bf9cdb65d44dad1efe37a354050 # v4.2.0
with:
pkgname: rustgis-bin
pkgbuild: aur/PKGBUILD
commit_username: Qiusheng Wu
commit_email: giswqs@gmail.com
ssh_private_key: ${{ env.AUR_KEY }}
commit_message: Update to ${{ needs.release.outputs.version }}
allow_empty_commits: false
updpkgsums: false
copr:
name: Fedora COPR
needs: release
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
continue-on-error: true
concurrency:
group: copr
cancel-in-progress: false
env:
COPR_CONFIG: ${{ secrets.COPR_CONFIG }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
if: env.COPR_CONFIG != ''
with:
persist-credentials: false
- name: Build the source RPM and submit it to giswqs/rustgis
if: env.COPR_CONFIG != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ needs.release.outputs.tag }}
VERSION: ${{ needs.release.outputs.version }}
DATE: ${{ needs.release.outputs.date }}
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq rpm appstream
# Pinned: this step holds the COPR token.
pipx install 'copr-cli==2.6'
mkdir -p ~/.config
(umask 077; printf '%s\n' "$COPR_CONFIG" > ~/.config/copr)
# Accept a partial paste of the API page's block: copr-cli needs the section header
# and copr_url, which are the same for everyone.
grep -q '^\[copr-cli\]' ~/.config/copr || sed -i '1i [copr-cli]' ~/.config/copr
grep -q '^copr_url' ~/.config/copr || echo 'copr_url = https://copr.fedorainfracloud.org' >> ~/.config/copr
# Show which keys are set (never the values).
grep -o '^[a-z_]* *=' ~/.config/copr | tr -d ' =' | paste -sd' '
src="$HOME/rpmbuild/SOURCES"
packaging/copr/render.sh "$VERSION" "$DATE" "$src"
appstreamcli validate --no-net "$src/org.rustgis.RustGIS.metainfo.xml"
gh release download "$TAG" --repo "$GITHUB_REPOSITORY" --dir "$src" \
--pattern "rustgis-$VERSION-1.x86_64.rpm" --pattern "rustgis-$VERSION-1.aarch64.rpm" \
--pattern SHA256SUMS
(cd "$src" && sha256sum --check --ignore-missing SHA256SUMS)
srpm="$(rpmbuild -bs "$src/rustgis.spec" --define "_topdir $HOME/rpmbuild" | sed -n 's/^Wrote: //p')"
[ -n "$srpm" ] || { echo "::error::rpmbuild wrote no source RPM"; exit 1; }
copr-cli build --nowait giswqs/rustgis "$srpm"
winget:
name: winget
needs: release
if: needs.release.outputs.publish == 'true'
runs-on: ubuntu-latest
continue-on-error: true
concurrency:
group: winget
cancel-in-progress: false
env:
WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}
steps:
- name: Open a pull request to microsoft/winget-pkgs
if: env.WINGET_TOKEN != ''
# Pinned to a commit: this step receives a token with access to the winget-pkgs fork.
uses: vedantmgoyal9/winget-releaser@b7370d4d152efdce803a26cc6ca9eee58cb2ad54 # v2
with:
identifier: OpenGeos.RustGIS
release-tag: ${{ needs.release.outputs.tag }}
installers-regex: 'windows-x86_64(-setup\.exe|\.msi)$'
fork-user: giswqs
token: ${{ env.WINGET_TOKEN }}