Skip to content

Commit 1cf5f69

Browse files
jeremyd2019dscho
andcommitted
Add a GitHub workflow to remove packages from the Pacman repository
Git for Windows relies on MSYS2 for a lot of packages, but also provides some packages of its own. Sometimes, Git for Windows even overrides (or "shadows") MSYS2's packages. And sometimes Git for Windows needs to stop overriding such packages. This new GitHub workflow allows for stopping to override MSYS2 packages by calling the shiny new `pacman-helper.sh quick_remove` functionality added in git-for-windows/build-extra#597. This will be used to clean up Git for Windows' Pacman repository after the most recent batch of MSYS2 updates to its i686 repository, see git-for-windows/git-sdk-32#39 (comment) for full details. Co-authored-by: Johannes Schindelin <[email protected]> Signed-off-by: Jeremy Drake <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 67701cd commit 1cf5f69

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: remove-packages-from-pacman-repository
2+
run-name: Remove ${{ inputs.packages }} from the Pacman repository
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
packages:
8+
description: 'The package name(s) to remove'
9+
required: true
10+
dry_run:
11+
description: 'Skip deployment (if non-empty)'
12+
required: false
13+
14+
env:
15+
PACKAGES_TO_REMOVE: "${{ github.event.inputs.packages }}"
16+
PACMANDRYRUN: "${{ github.event.inputs.dry_run }}"
17+
GPG_OPTIONS: "--batch --yes --no-tty --list-options no-show-photos --verify-options no-show-photos --pinentry-mode loopback"
18+
19+
jobs:
20+
build:
21+
if: github.event.repository.fork != true
22+
runs-on: 'windows-latest'
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Configure build
27+
shell: bash
28+
run: |
29+
HOME="${{ runner.temp }}\\home" &&
30+
echo "HOME=$HOME" >>$GITHUB_ENV &&
31+
mkdir -p "$HOME"
32+
33+
- name: Download Git for Windows SDK
34+
uses: git-for-windows/setup-git-for-windows-sdk@v1
35+
with:
36+
flavor: makepkg-git
37+
architecture: x86_64
38+
msys: true
39+
40+
- name: Clone build-extra
41+
shell: bash
42+
run: git clone --depth 1 --single-branch -b main https://github.com/git-for-windows/build-extra /usr/src/build-extra
43+
44+
- name: Get GPG key(s)
45+
timeout-minutes: 5
46+
shell: bash
47+
run: |
48+
for key in 57759F748D223F034D8BE870BB3AA74136C569BB
49+
do
50+
gpg $GPG_OPTIONS --recv-keys --batch --yes --keyserver hkp://keyserver.ubuntu.com "$key" &&
51+
echo "$key:6:" | gpg $GPG_OPTIONS --import-ownertrust ||
52+
exit 1
53+
done
54+
55+
- name: Prepare home directory for GPG signing
56+
if: env.GPGKEY != ''
57+
shell: bash
58+
run: |
59+
echo '${{secrets.PRIVGPGKEY}}' | tr % '\n' | gpg $GPG_OPTIONS --import &&
60+
mkdir -p "$HOME" &&
61+
git config --global gpg.program "/usr/src/build-extra/gnupg-with-gpgkey.sh" &&
62+
info="$(gpg --list-keys --with-colons "${GPGKEY%% *}" | cut -d : -f 1,10 | sed -n '/^uid/{s|uid:||p;q}')" &&
63+
git config --global user.name "${info% <*}" &&
64+
git config --global user.email "<${info#*<}"
65+
echo "PACKAGER=$info" >>$GITHUB_ENV
66+
env:
67+
GPGKEY: ${{secrets.GPGKEY}}
68+
69+
- uses: actions/create-github-app-token@v1
70+
id: pacman-repo-token
71+
with:
72+
app-id: ${{ secrets.GH_APP_ID }}
73+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
74+
owner: ${{ github.repository_owner }}
75+
repositories: pacman-repo
76+
77+
- name: Remove Pacman packages
78+
if: env.PACMANDRYRUN == 'true' || env.azure_blobs_token != ''
79+
shell: bash
80+
env:
81+
GPGKEY: ${{secrets.GPGKEY}}
82+
azure_blobs_token: ${{secrets.AZURE_BLOBS_TOKEN}}
83+
GITHUB_TOKEN: ${{ steps.pacman-repo-token.outputs.token }}
84+
run: /usr/src/build-extra/pacman-helper.sh quick_remove ${PACKAGES_TO_REMOVE}
85+
86+
- name: Clean up temporary files
87+
if: always()
88+
shell: bash
89+
run: |
90+
gpgconf --kill dirmngr &&
91+
gpgconf --kill gpg-agent &&
92+
{ rm -rf "$HOME" || echo "Gracefully leaving files undeleted" >&2; }

0 commit comments

Comments
 (0)