Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ on:
- '**/*.md'
- '**/*.asciidoc'

# Override the version if there is no tag release.
env:
ELASTIC_CI_POST_VERSION: ${{ startsWith(github.ref, 'refs/tags') && '' || github.run_id }}

jobs:
build:
runs-on: ubuntu-latest
Expand Down
39 changes: 29 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ on:
push:
tags:
- "v*.*.*"
branches:
- main

permissions:
contents: read

jobs:
test:
uses: ./.github/workflows/test.yml
uses: ./.github/workflows/test-release.yml
with:
full-matrix: true
enabled: ${{ startsWith(github.ref, 'refs/tags') }}

packages:
uses: ./.github/workflows/packages.yml
Expand All @@ -31,10 +34,16 @@ jobs:
with:
name: packages
path: dist
- name: Upload
- name: Upload pypi.org
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf
with:
repository-url: https://upload.pypi.org/legacy/
- name: Upload test.pypi.org
if: ${{ ! startsWith(github.ref, 'refs/tags') }}
uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf
with:
repository-url: https://test.pypi.org/legacy/

build-distribution:
uses: ./.github/workflows/build-distribution.yml
Expand All @@ -59,13 +68,15 @@ jobs:
name: build-distribution
path: ./build
- name: Publish lambda layers to AWS
if: startsWith(github.ref, 'refs/tags')
run: |
# Convert v1.2.3 to ver-1-2-3
VERSION=${GITHUB_REF_NAME/v/ver-}
VERSION=${VERSION//./-}

ELASTIC_LAYER_NAME="elastic-apm-python-${VERSION}" .ci/publish-aws.sh
- uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags')
with:
name: arn-file
path: ".arn-file.md"
Expand All @@ -75,6 +86,8 @@ jobs:
needs:
- build-distribution
runs-on: ubuntu-latest
env:
DOCKER_IMAGE_NAME: docker.elastic.co/observability/apm-agent-python
steps:
- uses: actions/checkout@v4
- uses: elastic/apm-pipeline-library/.github/actions/docker-login@current
Expand All @@ -91,30 +104,35 @@ jobs:
- id: setup-docker
name: Set up docker variables
run: |-
# version without v prefix (e.g. 1.2.3)
echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}"
echo "name=docker.elastic.co/observability/apm-agent-python" >> "${GITHUB_OUTPUT}"
if [ "${{ startsWith(github.ref, 'refs/tags') }}" == "false" ] ; then
# for testing purposes
echo "tag=test" >> "${GITHUB_OUTPUT}"
else
# version without v prefix (e.g. 1.2.3)
echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}"
fi
- name: Docker build
run: >-
docker build
-t ${{ steps.setup-docker.outputs.name }}:${{ steps.setup-docker.outputs.tag }}
-t ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }}
--build-arg AGENT_DIR=./build/dist/package/python
.
- name: Docker retag
run: >-
docker tag
${{ steps.setup-docker.outputs.name }}:${{ steps.setup-docker.outputs.tag }}
${{ steps.setup-docker.outputs.name }}:latest
${{ 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 ${{ steps.setup-docker.outputs.name }}:${{ steps.setup-docker.outputs.tag }}
docker push ${{ steps.setup-docker.outputs.name }}:latest
docker push --all-tags ${{ env.DOCKER_IMAGE_NAME }}

github-draft:
permissions:
contents: write
needs:
- publish-lambda-layers
if: startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -145,6 +163,7 @@ jobs:
with:
needs: ${{ toJSON(needs) }}
- uses: elastic/apm-pipeline-library/.github/actions/notify-build-status@current
if: startsWith(github.ref, 'refs/tags')
with:
status: ${{ steps.check.outputs.status }}
vaultUrl: ${{ secrets.VAULT_ADDR }}
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: test-release

on:
workflow_call:
inputs:
full-matrix:
description: "Run the full matrix"
required: true
type: boolean
ref:
description: "The git ref of elastic/apm-agent-python to run test workflow from."
required: false
type: string
enabled:
description: "Whether to run the workfow"
required: true
type: boolean
workflow_dispatch:
inputs:
full-matrix:
description: "Run the full matrix"
required: true
type: boolean
enabled:
description: "Whether to run the workfow"
required: true
type: boolean

jobs:
test:
if: ${{ inputs.enabled }}
uses: ./.github/workflows/test.yml
with:
full-matrix: ${{ inputs.full-matrix }}

run-if-disabled:
if: ${{ ! inputs.enabled }}
runs-on: ubuntu-latest
steps:
- run: echo "do something to help with the reusable workflows with needs"
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ def get_version():
for line in version_file:
if line.startswith("__version__"):
version_tuple = ast.literal_eval(line.split(" = ")[1])
return ".".join(map(str, version_tuple))
version_str = ".".join(map(str, version_tuple))
post_version = os.getenv("ELASTIC_CI_POST_VERSION")
if post_version:
return f"{version_str}.post{post_version}"
return version_str
return "unknown"


Expand Down