-
Notifications
You must be signed in to change notification settings - Fork 421
chore(ci): source code tampering protection for release #2301
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
Merged
leandrodamascena
merged 9 commits into
aws-powertools:develop
from
heitorlessa:ci/integrity-check
May 23, 2023
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7c25cf1
chore: create download-artifact, upload-artifact
heitorlessa 8663cee
chore: seals source code, separate quality check & build
heitorlessa 3da540a
chore: ruben's feedback
heitorlessa b0d4bb5
chore: document remaining sections; update release process doc
heitorlessa ef9d847
chore: include python bytecode in tarball for accurate hash verification
heitorlessa 470a717
chore: add hash verification
heitorlessa df7bcb7
chore: cleanup before review
heitorlessa 3241909
chore: fix build integrity hash reference
heitorlessa e792876
chore: upgrade download-artifact to v3 due to node deprecation warnings
heitorlessa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Download artifact | ||
description: Wrapper around GitHub's official action, with additional extraction before download | ||
|
||
# PROCESS | ||
# | ||
# 1. Downloads artifact using actions/download-artifact action | ||
# 2. Extracts and overwrites tarball previously uploaded | ||
# 3. Remove archive after extraction | ||
|
||
# NOTES | ||
# | ||
# Upload-artifact and download-artifact takes ~2m40s to upload 8MB | ||
# so this is custom action cuts down the entire operation to 1s | ||
# by uploading/extracting a tarball while relying on the official upload-artifact/download-artifact actions | ||
# | ||
|
||
# USAGE | ||
# | ||
# NOTE: Meant to be used with ./.github/actions/upload-artifact | ||
# | ||
# - name: Restore sealed source code | ||
# uses: ./.github/actions/download-artifact | ||
# with: | ||
# name: ${{ needs.seal.outputs.INTEGRITY_HASH }} | ||
# path: . | ||
|
||
# https://github.com/actions/download-artifact/blob/main/action.yml | ||
inputs: | ||
name: | ||
description: Artifact name | ||
required: true | ||
path: | ||
description: Destination path. By default, it will download to the current working directory. | ||
required: false | ||
default: . | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@cbed621e49e4c01b044d60f6c80ea4ed6328b281 # v2.1.1 | ||
with: | ||
name: ${{ inputs.name }} | ||
path: ${{ inputs.path }} | ||
|
||
- name: Extract artifacts | ||
run: tar -xvf "${ARCHIVE}" | ||
env: | ||
ARCHIVE: ${{ inputs.name }}.tar | ||
shell: bash | ||
working-directory: ${{ inputs.path }} | ||
|
||
- name: Remove archive | ||
run: rm -f "${ARCHIVE}" | ||
env: | ||
ARCHIVE: ${{ inputs.name }}.tar | ||
shell: bash | ||
working-directory: ${{ inputs.path }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Upload artifact | ||
description: Wrapper around GitHub's official action, with additional archiving before upload | ||
|
||
# PROCESS | ||
# | ||
# 1. Creates tarball excluding .git and *.pyc files | ||
# 2. Uploads tarball using actions/upload-artifact action, fail CI job if no file is found | ||
# 3. Remove archive after uploading it. | ||
|
||
# NOTES | ||
# | ||
# Upload-artifact and download-artifact takes ~2m40s to upload 8MB | ||
# so this is custom action cuts down the entire operation to 1s | ||
# by uploading/extracting a tarball while relying on the official upload-artifact/download-artifact actions | ||
# | ||
|
||
# USAGE | ||
# | ||
# NOTE: Meant to be used with ./.github/actions/download-artifact | ||
# | ||
# - name: Upload sealed source code | ||
# uses: ./.github/actions/upload-artifact | ||
# with: | ||
# name: ${{ steps.integrity.outputs.INTEGRITY_HASH }} | ||
# path: . | ||
|
||
# https://github.com/actions/upload-artifact/blob/main/action.yml | ||
inputs: | ||
name: | ||
description: Artifact name | ||
required: true | ||
path: | ||
description: > | ||
A file, directory or wildcard pattern that describes what to upload. | ||
|
||
You can pass multiple paths separated by space (e.g., dir1 dir2 file.txt). | ||
|
||
Paths and wildcard patterns must be tar command compatible. | ||
required: true | ||
retention-days: | ||
description: > | ||
Artifact retention in days. By default 1 day, max of 90 days, and 0 honours default repo retention. | ||
|
||
You can change max days in the repository settings. | ||
required: false | ||
default: "1" | ||
if-no-files-found: | ||
description: > | ||
Action to perform if no files are found: warn, error, ignore. By default, it fails fast with 'error'. | ||
|
||
Options: | ||
warn: Output a warning but do not fail the action | ||
error: Fail the action with an error message | ||
ignore: Do not output any warnings or errors, the action does not fail | ||
required: false | ||
default: error | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Archive artifacts | ||
run: | | ||
tar --exclude-vcs \ | ||
--exclude "*.pyc" \ | ||
-cvf "${ARCHIVE}" "${PATH_TO_ARCHIVE}" | ||
env: | ||
ARCHIVE: ${{ inputs.name }}.tar | ||
PATH_TO_ARCHIVE: ${{ inputs.path }} | ||
shell: bash | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 | ||
with: | ||
if-no-files-found: ${{ inputs.if-no-files-found }} | ||
name: ${{ inputs.name }} | ||
path: ${{ inputs.name }}.tar | ||
retention-days: ${{ inputs.retention-days }} | ||
|
||
- name: Remove archive | ||
run: rm -f "${ARCHIVE}" | ||
env: | ||
ARCHIVE: ${{ inputs.name }}.tar | ||
shell: bash |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️