3030
3131jobs :
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/') ) )
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
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
0 commit comments