Skip to content

Commit 9228ff0

Browse files
authored
chore(ci): sign vsix file VSCODE-493 (#632)
* chore: sign vsix * only sign on linux * echo logout from artifactory * wip * list signatures
1 parent ff5618c commit 9228ff0

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

.github/workflows/test-and-build.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,26 @@ jobs:
9999
run: npm run check-vsix-size
100100
shell: bash
101101

102+
- name: Sign .vsix
103+
if: runner.os == 'Linux'
104+
env:
105+
ARTIFACTORY_HOST: ${{ secrets.ARTIFACTORY_HOST }}
106+
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
107+
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
108+
GARASIGN_PASSWORD: ${{ secrets.GARASIGN_PASSWORD }}
109+
GARASIGN_USERNAME: ${{ secrets.GARASIGN_USERNAME }}
110+
run: |
111+
bash scripts/sign-vsix.sh
112+
ls *.vsix.sig
113+
shell: bash
114+
102115
- name: Upload artifacts
103116
uses: actions/upload-artifact@v2
104117
with:
105118
name: VSIX built on ${{ runner.os }}
106-
path: "*.vsix"
119+
path: |
120+
*.vsix
121+
*.vsix.sig
107122
108123
- name: Run Snyk Test
109124
if: runner.os == 'Linux'
@@ -149,7 +164,9 @@ jobs:
149164
--notes "Edit the release notes before publishing." \
150165
--target main \
151166
--draft \
152-
*.vsix
167+
*.vsix \
168+
*.vsix.sig
169+
153170
env:
154171
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155172
if: ${{ startsWith(github.ref, 'refs/tags/') && runner.os == 'Linux' }}

scripts/sign-vsix.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
3+
FILE_TO_SIGN=$(find . -maxdepth 1 -name '*.vsix' -print -quit)
4+
5+
if [ -z "$FILE_TO_SIGN" ]; then
6+
echo "Error: No .vsix file found in the current directory." >&2
7+
exit 1
8+
fi
9+
10+
required_vars=("ARTIFACTORY_PASSWORD" "ARTIFACTORY_HOST" "ARTIFACTORY_USERNAME" "GARASIGN_USERNAME" "GARASIGN_PASSWORD")
11+
for var in "${required_vars[@]}"; do
12+
if [ -z "${!var}" ]; then
13+
echo "Error: Environment variable $var is not set." >&2
14+
exit 1
15+
fi
16+
done
17+
18+
logout_artifactory() {
19+
docker logout "${ARTIFACTORY_HOST}" > /dev/null 2>&1
20+
echo "logged out from artifactory"
21+
}
22+
23+
trap logout_artifactory EXIT
24+
25+
26+
echo "${ARTIFACTORY_PASSWORD}" | docker login "${ARTIFACTORY_HOST}" -u "${ARTIFACTORY_USERNAME}" --password-stdin > /dev/null 2>&1
27+
28+
if [ $? -ne 0 ]; then
29+
echo "Docker login failed" >&2
30+
exit 1
31+
fi
32+
33+
docker run \
34+
--rm \
35+
-e GRS_CONFIG_USER1_USERNAME="${GARASIGN_USERNAME}" \
36+
-e GRS_CONFIG_USER1_PASSWORD="${GARASIGN_PASSWORD}" \
37+
-v "$(pwd):/tmp/workdir" \
38+
-w /tmp/workdir \
39+
${ARTIFACTORY_HOST}/release-tools-container-registry-local/garasign-gpg \
40+
/bin/bash -c "gpgloader && gpg --yes -v --armor -o /tmp/workdir/${FILE_TO_SIGN}.sig --detach-sign /tmp/workdir/${FILE_TO_SIGN}"
41+
42+
if [ $? -ne 0 ]; then
43+
echo "Signing failed" >&2
44+
exit 1
45+
fi

0 commit comments

Comments
 (0)