Skip to content

Commit 1b6143b

Browse files
committed
fix(ci): configure publishing parameters in a separate job, skip smoketest on altered packages, use altered distnames for publishing test only, restore original distribution name in pyproject.toml
1 parent 5fc8933 commit 1b6143b

4 files changed

Lines changed: 60 additions & 18 deletions

File tree

.github/workflows/release.yml

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,33 @@ env:
3030

3131
jobs:
3232

33+
setup:
34+
runs-on: ubuntu-latest
35+
outputs:
36+
distribution_name: ${steps.configure.distribution_name}
37+
publish_to: ${steps.configure.publish_to}
38+
publish_env: ${steps.configure.publish_env}
39+
steps:
40+
id: configure
41+
shell: bash
42+
run: |
43+
case "${github.ref_name}" in
44+
"ci/"*)
45+
echo "publish_env=testpypi" >> $GITHUB_OUTPUT ;
46+
echo "distribution_name=${env.testpypi_project}" >> $GITHUB_OUTPUT ;
47+
echo "publish_to=https://test.pypi.org/project/${env.testpypi_project}" >> $GITHUB_OUTPUT ;
48+
;;
49+
master)
50+
echo "publish_env=pypi" >> $GITHUB_OUTPUT ;
51+
echo "distribution_name=${env.pypi_project}" >> $GITHUB_OUTPUT ;
52+
echo "publish_to=https://pypi.org/project/${env.pypi_project}" >> $GITHUB_OUTPUT ;
53+
*)
54+
echo "publish_env=SKIP" >> $GITHUB_OUTPUT ;
55+
echo "distribution_name=${env.pypi_project}" >> $GITHUB_OUTPUT ;
56+
echo "publish_to=https://test.pypi.org/project/${env.pypi_project}" >> $GITHUB_OUTPUT ;
57+
;;
58+
esac
59+
3360
release:
3461
runs-on: ubuntu-latest
3562
if: github.event_name == 'workflow_dispatch' || (github.event_name=='push' && startsWith(github.ref_name,'ci/') ) || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.head_branch == 'master' || startsWith(github.event.workflow_run.head_branch, 'ci/') ) )
@@ -48,7 +75,7 @@ jobs:
4875
GIT_COMMITTER_NAME: appland-release
4976
GIT_COMMITTER_EMAIL: release@app.land
5077
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
DISTRIBUTION_NAME: ${{ github.ref_name=='master' && env.pypi_project || env.testpypi_project }}
78+
DISTRIBUTION_NAME: ${{ needs.setup.outputs.distribution_name }}
5279
run: |
5380
if [ "$DRY_RUN" = "true" ]; then
5481
semantic-release --dry-run
@@ -74,7 +101,8 @@ jobs:
74101
smoketest:
75102
runs-on: ubuntu-latest
76103
needs: release
77-
if: github.event.inputs.dry_run!='true'
104+
if: github.event.inputs.dry_run!='true'
105+
continue-on-error: needs.setup.outputs.distribution_name!='appmap' # altered names won't work anyway
78106
steps:
79107
- uses: actions/checkout@v5
80108
- uses: ./.github/actions/refetch-artifacts
@@ -87,29 +115,29 @@ jobs:
87115
- run: ci/scripts/run_tests.sh
88116
env:
89117
SMOKETEST_DOCKER_IMAGE: python:3.12-slim
90-
DISTRIBUTION_NAME: ${{ github.ref_name=='master' && env.pypi_project || env.testpypi_project }}
118+
DISTRIBUTION_NAME: ${{ needs.setup.outputs.distribution_name }}
91119

92120
# as a workaround to ownership issues (lost access to project)
93-
pypi:
94-
name: upload release to PyPI
121+
publish:
122+
name: publish package on PyPI
95123
needs: ['release','smoketest']
96-
if: (( github.event.inputs.dry_run != 'true' ) && ((github.ref_name == 'master') || startsWith(github.ref_name,'ci/') ))
124+
if: (( github.event.inputs.dry_run != 'true' ) && (needs.setup.outputs.publish_env != 'SKIP') )
97125
runs-on: ubuntu-latest
98126
environment:
99-
name: ( github.ref_name=='master' && 'pypi' || 'testpypi' )
100-
url: ( github.ref_name=='master' && 'https://pypi.org/project/${{ env.pypi_project }}' || 'https://test.pypi.org/project/${{ env.testpypi_project }}' )
127+
name: needs.setup_outputs.publish_env
128+
url: needs.setup_outputs.publish_to
101129
permissions:
102130
id-token: write
103131
steps:
104132
- uses: actions/checkout@v5
105133
- uses: ./.github/actions/refetch-artifacts
106134

107135
- name: Publish to PyPI
108-
if: github.ref_name == 'master'
136+
if: needs.setup.outputs.publish_env=='pypi'
109137
uses: pypa/gh-action-pypi-publish@release/v1
110138

111139
- name: Publish to TestPyPI
112-
if: github.ref_name != 'master'
140+
if: needs.setup.outputs.publish_env='testpypi'
113141
uses: pypa/gh-action-pypi-publish@release/v1
114142
with:
115143
repository-url: https://test.pypi.org/uploads/legacy

.releaserc.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,14 @@ plugins:
3636
- files: [pyproject.toml] # optional: SemVer prerelease -> PEP440 ("1.2.3-rc.10" -> "1.2.3rc10" )
3737
from: '^version = "(\\d+\\.\\d+\\.\\d+)-(a|b|rc)\\.(\\d+)"'
3838
to: 'version = "\\1\\2\\3"'
39-
- - '@google/semantic-release-replace-plugin' # optional enforcement of distribution name
40-
- replacements:
41-
- files: [pyproject.toml] # optional: SemVer prerelease -> PEP440 ("1.2.3-dev.1" -> "1.2.3.dev1")
42-
from: ^name = ".*?"
43-
to: name = "${process.env.DISTRIBUTION_NAME}"
4439
- - '@semantic-release/git'
4540
- assets:
4641
- CHANGELOG.md
4742
- pyproject.toml
4843
- - '@semantic-release/exec'
4944
- prepareCmd: |
50-
poetry build && /bin/bash ./ci/scripts/patch_artifacts_if_distribution_name_is_altered.sh dist/*.whl dist/*.tar.gz
51-
- - '@semantic-release/github'
45+
/bin/bash ./ci/scripts/build_with_poetry.sh
46+
- - '@semantic-release/github':
5247
- assets:
5348
- dist/*.whl
5449
- dist/*.tar.gz

ci/scripts/build_with_poetry.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
if [ -z "$DISTRIBUTION_NAME" ] || [ "$DISTRIBUTION_NAME" = "appmap" ] ; then
7+
exec poetry build $*
8+
fi
9+
10+
echo "Altering distribution name to $DISTRIBUTION_NAME"
11+
12+
cp -v pyproject.toml /tmp/pyproject.bak
13+
sed -i -e "s/^name = \".*\"/name = \"${DISTRIBUTION_NAME}\"/" pyproject.toml
14+
grep -n 'name = "' pyproject.toml
15+
16+
poetry build $*
17+
18+
echo "Not patching artifacts with Provides-Dist, they won't work anyway (this flow is solely for publishing test)"
19+
cp -v /tmp/pyproject.bak pyproject.toml

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool.poetry]
2-
name = "appmap-dev"
2+
name = "appmap"
33
version = "2.2.0-dev.11"
44
description = "Create AppMap files by recording a Python application."
55
readme = "README.md"

0 commit comments

Comments
 (0)