-
Notifications
You must be signed in to change notification settings - Fork 230
github-action: enable provenance #2014
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
Changes from all commits
595855c
98a81e8
6128f3a
3ceefb1
6969613
15a5853
91f43d1
b007885
f402a15
b85ef4c
ae358c0
22b949d
8c53528
1bb2e39
12dbdbb
6dbf25c
7cf9b7b
902ffba
c87ffcf
b37d910
ca9ae53
5ae9aeb
cc74e8d
81793ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
|
||
name: common build distribution tasks | ||
description: Run the build distribution | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Build lambda layer zip | ||
run: ./dev-utils/make-distribution.sh | ||
shell: bash | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: build-distribution | ||
path: ./build/ | ||
if-no-files-found: error |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
|
||
name: common package tasks | ||
description: Run the packages | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
- name: Override the version if there is no tag release. | ||
run: | | ||
if [[ "${GITHUB_REF}" != refs/tags/* ]]; then | ||
echo "ELASTIC_CI_POST_VERSION=${{ github.run_id }}" >> "${GITHUB_ENV}" | ||
fi | ||
shell: bash | ||
- name: Build packages | ||
run: ./dev-utils/make-packages.sh | ||
shell: bash | ||
- name: Upload Packages | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: packages | ||
path: | | ||
dist/*.whl | ||
dist/*tar.gz | ||
- name: generate build provenance | ||
uses: github-early-access/generate-build-provenance@main | ||
with: | ||
subject-path: "${{ github.workspace }}/dist/*" |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,13 @@ jobs: | |
enabled: ${{ startsWith(github.ref, 'refs/tags') }} | ||
|
||
packages: | ||
uses: ./.github/workflows/packages.yml | ||
permissions: | ||
id-token: write | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/packages | ||
|
||
publish-pypi: | ||
needs: | ||
|
@@ -46,7 +52,17 @@ jobs: | |
repository-url: https://test.pypi.org/legacy/ | ||
|
||
build-distribution: | ||
uses: ./.github/workflows/build-distribution.yml | ||
permissions: | ||
id-token: write | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: ./.github/actions/build-distribution | ||
- name: generate build provenance | ||
uses: github-early-access/generate-build-provenance@main | ||
with: | ||
subject-path: "${{ github.workspace }}/build/dist/elastic-apm-python-lambda-layer.zip" | ||
|
||
publish-lambda-layers: | ||
needs: | ||
|
@@ -63,7 +79,7 @@ jobs: | |
secrets: | | ||
secret/observability-team/ci/service-account/apm-agent-python access_key_id | AWS_ACCESS_KEY_ID ; | ||
secret/observability-team/ci/service-account/apm-agent-python secret_access_key | AWS_SECRET_ACCESS_KEY | ||
- uses: actions/download-artifact@v3 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: build-distribution | ||
path: ./build | ||
|
@@ -86,6 +102,9 @@ jobs: | |
needs: | ||
- build-distribution | ||
runs-on: ubuntu-latest | ||
permissions: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the build attestation |
||
id-token: write | ||
contents: write | ||
env: | ||
DOCKER_IMAGE_NAME: docker.elastic.co/observability/apm-agent-python | ||
steps: | ||
|
@@ -97,7 +116,7 @@ jobs: | |
url: ${{ secrets.VAULT_ADDR }} | ||
roleId: ${{ secrets.VAULT_ROLE_ID }} | ||
secretId: ${{ secrets.VAULT_SECRET_ID }} | ||
- uses: actions/download-artifact@v3 | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: build-distribution | ||
path: ./build | ||
|
@@ -107,25 +126,30 @@ jobs: | |
if [ "${{ startsWith(github.ref, 'refs/tags') }}" == "false" ] ; then | ||
# for testing purposes | ||
echo "tag=test" >> "${GITHUB_OUTPUT}" | ||
echo "latest=test-latest" >> "${GITHUB_OUTPUT}" | ||
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To help with creating docker images on the fly and use them even for testing the release in a feature branch or main. |
||
else | ||
# version without v prefix (e.g. 1.2.3) | ||
echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}" | ||
echo "latest=latest" >> "${GITHUB_OUTPUT}" | ||
fi | ||
- name: Docker build | ||
run: >- | ||
docker build | ||
-t ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }} | ||
--build-arg AGENT_DIR=./build/dist/package/python | ||
. | ||
- name: Docker retag | ||
run: >- | ||
docker tag | ||
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }} | ||
${{ env.DOCKER_IMAGE_NAME }}:latest | ||
- name: Docker push | ||
if: startsWith(github.ref, 'refs/tags') | ||
run: |- | ||
docker push --all-tags ${{ env.DOCKER_IMAGE_NAME }} | ||
- name: Build and push image | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Required for the attestation |
||
id: push | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }} | ||
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.latest }} | ||
build-args: | | ||
AGENT_DIR=./build/dist/package/python | ||
|
||
- name: Attest image | ||
uses: github-early-access/generate-build-provenance@main | ||
with: | ||
subject-name: "${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch!! Fixing it now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interestingly, it works as is: https://github.com/elastic/apm-agent-python/attestations/739913 |
||
subject-digest: ${{ steps.push.outputs.digest }} | ||
push-to-registry: false | ||
|
||
github-draft: | ||
permissions: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
# | ||
# Make a Python APM agent distribution | ||
# | ||
|
||
echo "::group::Install wheel" | ||
pip install --user wheel | ||
echo "::endgroup::" | ||
|
||
echo "::group::Building universal wheel" | ||
python setup.py bdist_wheel | ||
echo "::endgroup::" | ||
|
||
echo "::group::Building source distribution" | ||
python setup.py sdist | ||
echo "::endgroup::" |
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.
Faster builds