44 push :
55 tags :
66 - " v*.*.*"
7+ branches :
8+ - main
79
810permissions :
911 contents : read
1012
1113jobs :
1214 test :
13- uses : ./.github/workflows/test.yml
15+ uses : ./.github/workflows/test-release .yml
1416 with :
1517 full-matrix : true
18+ enabled : ${{ startsWith(github.ref, 'refs/tags') }}
1619
1720 packages :
1821 uses : ./.github/workflows/packages.yml
@@ -31,10 +34,16 @@ jobs:
3134 with :
3235 name : packages
3336 path : dist
34- - name : Upload
37+ - name : Upload pypi.org
38+ if : startsWith(github.ref, 'refs/tags')
3539 uses : pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf
3640 with :
3741 repository-url : https://upload.pypi.org/legacy/
42+ - name : Upload test.pypi.org
43+ if : ${{ ! startsWith(github.ref, 'refs/tags') }}
44+ uses : pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf
45+ with :
46+ repository-url : https://test.pypi.org/legacy/
3847
3948 build-distribution :
4049 uses : ./.github/workflows/build-distribution.yml
@@ -59,13 +68,15 @@ jobs:
5968 name : build-distribution
6069 path : ./build
6170 - name : Publish lambda layers to AWS
71+ if : startsWith(github.ref, 'refs/tags')
6272 run : |
6373 # Convert v1.2.3 to ver-1-2-3
6474 VERSION=${GITHUB_REF_NAME/v/ver-}
6575 VERSION=${VERSION//./-}
6676
6777 ELASTIC_LAYER_NAME="elastic-apm-python-${VERSION}" .ci/publish-aws.sh
6878 - uses : actions/upload-artifact@v4
79+ if : startsWith(github.ref, 'refs/tags')
6980 with :
7081 name : arn-file
7182 path : " .arn-file.md"
7586 needs :
7687 - build-distribution
7788 runs-on : ubuntu-latest
89+ env :
90+ DOCKER_IMAGE_NAME : docker.elastic.co/observability/apm-agent-python
7891 steps :
7992 - uses : actions/checkout@v4
8093 - uses : elastic/apm-pipeline-library/.github/actions/docker-login@current
@@ -91,30 +104,35 @@ jobs:
91104 - id : setup-docker
92105 name : Set up docker variables
93106 run : |-
94- # version without v prefix (e.g. 1.2.3)
95- echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}"
96- echo "name=docker.elastic.co/observability/apm-agent-python" >> "${GITHUB_OUTPUT}"
107+ if [ "${{ startsWith(github.ref, 'refs/tags') }}" == "false" ] ; then
108+ # for testing purposes
109+ echo "tag=test" >> "${GITHUB_OUTPUT}"
110+ else
111+ # version without v prefix (e.g. 1.2.3)
112+ echo "tag=${GITHUB_REF_NAME/v/}" >> "${GITHUB_OUTPUT}"
113+ fi
97114 - name : Docker build
98115 run : >-
99116 docker build
100- -t ${{ steps.setup-docker.outputs.name }}:${{ steps.setup-docker.outputs.tag }}
117+ -t ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }}
101118 --build-arg AGENT_DIR=./build/dist/package/python
102119 .
103120 - name : Docker retag
104121 run : >-
105122 docker tag
106- ${{ steps.setup-docker.outputs.name }}:${{ steps.setup-docker.outputs.tag }}
107- ${{ steps.setup-docker.outputs.name }}:latest
123+ ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.setup-docker.outputs.tag }}
124+ ${{ env.DOCKER_IMAGE_NAME }}:latest
108125 - name : Docker push
126+ if : startsWith(github.ref, 'refs/tags')
109127 run : |-
110- docker push ${{ steps.setup-docker.outputs.name }}:${{ steps.setup-docker.outputs.tag }}
111- docker push ${{ steps.setup-docker.outputs.name }}:latest
128+ docker push --all-tags ${{ env.DOCKER_IMAGE_NAME }}
112129
113130 github-draft :
114131 permissions :
115132 contents : write
116133 needs :
117134 - publish-lambda-layers
135+ if : startsWith(github.ref, 'refs/tags')
118136 runs-on : ubuntu-latest
119137 steps :
120138 - uses : actions/checkout@v4
@@ -145,6 +163,7 @@ jobs:
145163 with :
146164 needs : ${{ toJSON(needs) }}
147165 - uses : elastic/apm-pipeline-library/.github/actions/notify-build-status@current
166+ if : startsWith(github.ref, 'refs/tags')
148167 with :
149168 status : ${{ steps.check.outputs.status }}
150169 vaultUrl : ${{ secrets.VAULT_ADDR }}
0 commit comments