Skip to content

Commit 7a89262

Browse files
committed
build-git-installers: publish gpg public key
Update build-git-installers workflow to publish `microsoft/git`'s GPG public key as part of each release. Add explanation for how to use this key to verify the Debian package's signature to the README.
1 parent 2914d7b commit 7a89262

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed

.github/workflows/build-git-installers.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ jobs:
630630
create-github-release:
631631
runs-on: ubuntu-latest
632632
needs: [validate-installers]
633+
env:
634+
AZURE_VAULT: ${{ secrets.AZURE_VAULT }}
635+
GPG_PUBLIC_KEY_SECRET_NAME: ${{ secrets.GPG_PUBLIC_KEY_SECRET_NAME }}
636+
environment: release
633637
if: |
634638
success() ||
635639
(needs.create-linux-artifacts.result == 'skipped' &&
@@ -641,21 +645,37 @@ jobs:
641645
with:
642646
name: win-portable-x86_64
643647
path: win-portable-x86_64
648+
644649
- name: Download Windows x86_64 installer
645650
uses: actions/download-artifact@v3
646651
with:
647652
name: win-installer-x86_64
648653
path: win-installer-x86_64
654+
649655
- name: Download macOS artifacts
650656
uses: actions/download-artifact@v3
651657
with:
652658
name: macos-artifacts
653659
path: macos-artifacts
660+
654661
- name: Download Debian package
655662
uses: actions/download-artifact@v3
656663
with:
657664
name: linux-artifacts
658665
path: deb-package
666+
667+
- name: Log into Azure
668+
uses: azure/login@v1
669+
with:
670+
creds: ${{ secrets.AZURE_CREDENTIALS }}
671+
672+
- name: Download GPG public key signature file
673+
run: |
674+
az keyvault secret show --name "$GPG_PUBLIC_KEY_SECRET_NAME" \
675+
--vault-name "$AZURE_VAULT" --query "value" \
676+
| sed -e 's/^"//' -e 's/"$//' | base64 -d >msft-git-public.asc
677+
mv msft-git-public.asc deb-package
678+
659679
- uses: actions/github-script@v6
660680
with:
661681
script: |

README.md

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,59 @@ Or you can run the `git update-microsoft-git` command, which will run those brew
114114
## Linux
115115
### Ubuntu/Debian distributions
116116

117-
On newer distributions*, you can download the most recent Debian package from
118-
the [releases page](https://github.com/microsoft/git/releases/latest) (or
119-
using a tool such as `wget`) then run:
117+
On newer distributions*, you can install using the most recent Debian package.
118+
To download and validate the signature of this package, run the following:
120119

121120
```shell
122-
sudo dpkg -i <path to package>
121+
# Install needed packages
122+
apt-get install -y curl debsig-verify
123+
124+
# Download public key signature file
125+
curl -s https://api.github.com/repos/microsoft/git/releases/latest \
126+
| grep -E 'browser_download_url.*msft-git-public.asc' \
127+
| cut -d : -f 2,3 \
128+
| tr -d \" \
129+
| xargs -I 'url' curl -L -o msft-git-public.asc 'url'
130+
131+
# De-armor public key signature file
132+
gpg --output msft-git-public.gpg --dearmor msft-git-public.asc
133+
134+
# Note that the fingerprint of this key is "B8F12E25441124E1", which you can
135+
# determine by running:
136+
gpg --show-keys msft-git-public.asc | head -n 2 | tail -n 1 | tail -c 17
137+
138+
# Copy de-armored public key to debsig keyring folder
139+
mkdir /usr/share/debsig/keyrings/B8F12E25441124E1
140+
mv msft-git-public.gpg /usr/share/debsig/keyrings/B8F12E25441124E1/
141+
142+
# Create an appropriate policy file
143+
mkdir /etc/debsig/policies/B8F12E25441124E1
144+
cat > /etc/debsig/policies/B8F12E25441124E1/generic.pol << EOL
145+
<?xml version="1.0"?>
146+
<!DOCTYPE Policy SYSTEM "https://www.debian.org/debsig/1.0/policy.dtd">
147+
<Policy xmlns="https://www.debian.org/debsig/1.0/">
148+
<Origin Name="Microsoft Git" id="B8F12E25441124E1" Description="Microsoft Git public key"/>
149+
<Selection>
150+
<Required Type="origin" File="msft-git-public.gpg" id="B8F12E25441124E1"/>
151+
</Selection>
152+
<Verification MinOptional="0">
153+
<Required Type="origin" File="msft-git-public.gpg" id="B8F12E25441124E1"/>
154+
</Verification>
155+
</Policy>
156+
EOL
157+
158+
# Download Debian package
159+
curl -s https://api.github.com/repos/microsoft/git/releases/latest \
160+
| grep "browser_download_url.*deb" \
161+
| cut -d : -f 2,3 \
162+
| tr -d \" \
163+
| xargs -I 'url' curl -L -o msft-git.deb 'url'
164+
165+
# Verify
166+
debsig-verify msft-git.deb
167+
168+
# Install
169+
sudo dpkg -i msft-git.deb
123170
```
124171

125172
Double-check that you have the right version by running these commands,

0 commit comments

Comments
 (0)