Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): sign vsix file VSCODE-493 #632

Merged
merged 5 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .github/workflows/test-and-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,26 @@ jobs:
run: npm run check-vsix-size
shell: bash

- name: Sign .vsix
if: runner.os == 'Linux'
env:
ARTIFACTORY_HOST: ${{ secrets.ARTIFACTORY_HOST }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
GARASIGN_PASSWORD: ${{ secrets.GARASIGN_PASSWORD }}
GARASIGN_USERNAME: ${{ secrets.GARASIGN_USERNAME }}
run: |
bash scripts/sign-vsix.sh
ls *.vsix.sig
shell: bash

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: VSIX built on ${{ runner.os }}
path: "*.vsix"
path: |
*.vsix
*.vsix.sig

- name: Run Snyk Test
if: runner.os == 'Linux'
Expand Down Expand Up @@ -149,7 +164,9 @@ jobs:
--notes "Edit the release notes before publishing." \
--target main \
--draft \
*.vsix
*.vsix \
*.vsix.sig

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ startsWith(github.ref, 'refs/tags/') && runner.os == 'Linux' }}
45 changes: 45 additions & 0 deletions scripts/sign-vsix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

FILE_TO_SIGN=$(find . -maxdepth 1 -name '*.vsix' -print -quit)

if [ -z "$FILE_TO_SIGN" ]; then
echo "Error: No .vsix file found in the current directory." >&2
exit 1
fi

required_vars=("ARTIFACTORY_PASSWORD" "ARTIFACTORY_HOST" "ARTIFACTORY_USERNAME" "GARASIGN_USERNAME" "GARASIGN_PASSWORD")
for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
echo "Error: Environment variable $var is not set." >&2
exit 1
fi
done

logout_artifactory() {
docker logout "${ARTIFACTORY_HOST}" > /dev/null 2>&1
echo "logged out from artifactory"
}

trap logout_artifactory EXIT


echo "${ARTIFACTORY_PASSWORD}" | docker login "${ARTIFACTORY_HOST}" -u "${ARTIFACTORY_USERNAME}" --password-stdin > /dev/null 2>&1

if [ $? -ne 0 ]; then
echo "Docker login failed" >&2
exit 1
fi

docker run \
--rm \
-e GRS_CONFIG_USER1_USERNAME="${GARASIGN_USERNAME}" \
-e GRS_CONFIG_USER1_PASSWORD="${GARASIGN_PASSWORD}" \
-v "$(pwd):/tmp/workdir" \
-w /tmp/workdir \
${ARTIFACTORY_HOST}/release-tools-container-registry-local/garasign-gpg \
/bin/bash -c "gpgloader && gpg --yes -v --armor -o /tmp/workdir/${FILE_TO_SIGN}.sig --detach-sign /tmp/workdir/${FILE_TO_SIGN}"

if [ $? -ne 0 ]; then
echo "Signing failed" >&2
exit 1
fi
Loading