Skip to content

Commit

Permalink
ci: add gpg signing of build artifacts
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Moore <122481442+moorec-aws@users.noreply.github.com>
  • Loading branch information
moorec-aws committed Mar 19, 2024
1 parent cda6be4 commit 9ed0478
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 50 deletions.
91 changes: 45 additions & 46 deletions .github/workflows/release_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,30 @@ jobs:
run: |
export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token --domain ${{ secrets.CODEARTIFACT_DOMAIN }} --domain-owner ${{ secrets.CODEARTIFACT_ACCOUNT_ID }} --query authorizationToken --output text --region us-west-2)
pip install --upgrade hatch
hatch build
# TODO: Uncomment below once the Deadline Cloud PGP key is available
# - name: Configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: ${{ secrets.AWS_PGP_KEY_SECRET_ROLE }}
# aws-region: us-west-2
# mask-aws-account-id: true

# - name: Import PGP Key
# run: |
# export SECRET_STRING="$(aws secretsmanager get-secret-value --secret-id ${{ secrets.AWS_PGP_KEY_SECRET }} --query 'SecretString')"
# printenv SECRET_STRING | jq -r '. | fromjson | .PrivateKey' | gpg --batch --pinentry-mode loopback --import --armor

# PGP_KEY_PASSPHRASE=$(printenv SECRET_STRING | jq -r '. | fromjson | .Passphrase')
# echo "::add-mask::$PGP_KEY_PASSPHRASE"
# echo "PGP_KEY_PASSPHRASE=$PGP_KEY_PASSPHRASE" >> $GITHUB_ENV

# - name: Sign
# run: |
# for file in dist/*; do
# printenv PGP_KEY_PASSPHRASE | gpg --batch --pinentry-mode loopback --local-user "Open Job Description" --passphrase-fd 0 --output $file.sig --detach-sign $file
# echo "Created signature file for $file"
# done
hatch -v build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_PGP_KEY_SECRET_ROLE }}
aws-region: us-west-2
mask-aws-account-id: true

- name: Import PGP Key
run: |
export SECRET_STRING="$(aws secretsmanager get-secret-value --secret-id ${{ secrets.AWS_PGP_KEY_SECRET }} --query 'SecretString')"
printenv SECRET_STRING | jq -r '. | fromjson | .PrivateKey' | gpg --batch --pinentry-mode loopback --import --armor
PGP_KEY_PASSPHRASE=$(printenv SECRET_STRING | jq -r '. | fromjson | .Passphrase')
echo "::add-mask::$PGP_KEY_PASSPHRASE"
echo "PGP_KEY_PASSPHRASE=$PGP_KEY_PASSPHRASE" >> $GITHUB_ENV
- name: Sign
run: |
for file in dist/*; do
printenv PGP_KEY_PASSPHRASE | gpg --batch --pinentry-mode loopback --local-user "AWS Deadline Cloud" --passphrase-fd 0 --output $file.sig --detach-sign $file
echo "Created signature file for $file"
done
- name: PushRelease
env:
Expand All @@ -134,6 +133,26 @@ jobs:
git push origin $TAG
gh release create $TAG dist/* --notes "$RELEASE_NOTES"
PublishToInternal:
needs: Release
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_CODEBUILD_RELEASE_PUBLISH_ROLE }}
aws-region: us-west-2
mask-aws-account-id: true

- name: Run CodeBuild
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: ${{ github.event.repository.name }}-Publish
hide-cloudwatch-logs: true

PublishToRepository:
needs: Release
runs-on: ubuntu-latest
Expand Down Expand Up @@ -176,7 +195,7 @@ jobs:
pip install --upgrade twine
- name: Build
run: hatch build
run: hatch -v build

- name: Publish to Repository
run: |
Expand All @@ -196,23 +215,3 @@ jobs:
# # See https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-pypi
# - name: Publish to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1

PublishToInternal:
needs: Release
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_CODEBUILD_RELEASE_PUBLISH_ROLE }}
aws-region: us-west-2
mask-aws-account-id: true

- name: Run CodeBuild
uses: aws-actions/aws-codebuild-run-build@v1
with:
project-name: ${{ github.event.repository.name }}-Publish
hide-cloudwatch-logs: true
4 changes: 2 additions & 2 deletions .github/workflows/reuse_python_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ jobs:
pip install --upgrade hatch
- name: Run Linting
run: hatch run lint
run: hatch -v run lint

- name: Run Build
run: hatch build
run: hatch -v build

- name: Run Tests
run: hatch run test -vv
4 changes: 2 additions & 2 deletions pipeline/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ set -e
pip install --upgrade pip
pip install --upgrade hatch
pip install --upgrade twine
hatch run codebuild:lint
hatch -v run codebuild:lint
hatch run codebuild:test
hatch run codebuild:build
hatch -v run codebuild:build

0 comments on commit 9ed0478

Please sign in to comment.