Skip to content

Commit c100f55

Browse files
committed
update pipeline to do test publish with incremental build number for PR & inputs
1 parent 6bae8a3 commit c100f55

File tree

1 file changed

+29
-41
lines changed

1 file changed

+29
-41
lines changed

.github/workflows/publish.yml

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,72 +13,60 @@ on:
1313
- "main"
1414
paths:
1515
- "aws_fusion/__init__.py"
16+
17+
pull_request:
18+
branches:
19+
- "main"
1620

1721
concurrency: publish
1822

1923
env:
2024
PYTHON_VERSION: '3.11'
25+
TEST_PUBLISH: ${{ inputs.test_publish && inputs.test_publish || github.event_name == 'pull_request' }}
2126

2227
jobs:
23-
tagging:
28+
publish:
2429
runs-on: ubuntu-latest
25-
name: Auto Tagging
30+
name: Publish
2631
permissions:
2732
contents: write
28-
outputs:
29-
tag: ${{ steps.package_info.outputs.tag }}
30-
tag_pre_exist: ${{ steps.package_info.outputs.tag_pre_exist }}
33+
id-token: write
34+
environment:
35+
name: pypi
36+
url: "https://${{ env.TEST_PUBLISH && 'test.' || '' }}pypi.org/project/aws-fusion"
3137
steps:
3238
- name: Checkout 🔔
33-
uses: actions/checkout@v3
39+
uses: actions/checkout@v4
3440
with:
3541
fetch-depth: 0
3642

3743
- name: Setup Python
3844
uses: actions/setup-python@v4
3945
with:
4046
python-version: ${{ env.PYTHON_VERSION }}
41-
42-
- name: Get package information
47+
48+
- name: Package Info
4349
id: package_info
4450
run: |
4551
current_version=$(./setup.py --version)
46-
47-
tag_pre_exist=false
48-
if git rev-parse "refs/tags/v$current_version" >/dev/null 2>&1; then
49-
echo "::warning title=Tag already exists::v${current_version}"
50-
tag_pre_exist=true
52+
53+
if [[ "${{ env.TEST_PUBLISH }}" == "true" ]]; then
54+
updated_version="${current_version}-${{ github.run_number }}"
55+
sed -iE "s|(__version__\s+=\s['\"])${current_version}(['\"])|\1${updated_version}\2|g" aws_fusion/__init__.py
56+
cat aws_fusion/__init__.py
57+
current_version="${updated_version}"
5158
fi
52-
53-
echo "tag=v${current_version}" >> "$GITHUB_OUTPUT"
54-
echo "tag_pre_exist=${tag_pre_exist}" >> "$GITHUB_OUTPUT"
55-
59+
60+
echo "::notice file=aws_fusion/__init__.py::version=${current_version}"
61+
echo "version=${current_version}" >> "$GITHUB_OUTPUT"
62+
5663
- name: Add git tag
57-
if: ${{ steps.package_info.outputs.tag_pre_exist == 'false' }}
64+
if: ${{ !env.TEST_PUBLISH }}
5865
run: |
59-
git tag ${{ steps.package_info.outputs.tag }}
60-
git push origin ${{ steps.package_info.outputs.tag }}
61-
62-
publish:
63-
needs: tagging
64-
if: ${{ inputs.test_publish || needs.tagging.outputs.tag_pre_exist == 'false' }}
65-
runs-on: ubuntu-latest
66-
name: "${{ inputs.test_publish && 'Test ' || '' }}Publish"
67-
environment:
68-
name: pypi
69-
url: "https://${{ inputs.test_publish && 'test.' || '' }}pypi.org/project/aws-fusion"
70-
permissions:
71-
id-token: write
72-
steps:
73-
- name: Checkout 🔔
74-
uses: actions/checkout@v3
75-
with:
76-
ref: ${{ needs.tagging.outputs.tag }}
66+
tag="v${{ steps.package_info.outputs.version }}"
7767
78-
- name: Set up Python
79-
uses: actions/setup-python@v4
80-
with:
81-
python-version: ${{ env.PYTHON_VERSION }}
68+
git tag ${tag}
69+
git push origin ${tag}
8270
8371
- name: Install dependencies
8472
run: |
@@ -91,5 +79,5 @@ jobs:
9179
- name: Publish release distributions to PyPI
9280
uses: pypa/gh-action-pypi-publish@release/v1
9381
with:
94-
repository-url: ${{ inputs.test_publish && 'https://test.pypi.org/legacy/' || '' }}
82+
repository-url: ${{ env.TEST_PUBLISH && 'https://test.pypi.org/legacy/' || '' }}
9583

0 commit comments

Comments
 (0)