Skip to content

Commit d63f090

Browse files
authored
fix: automatic publish on version change (#214)
1 parent f555f8b commit d63f090

File tree

3 files changed

+19
-52
lines changed

3 files changed

+19
-52
lines changed

.github/workflows/cd.yaml

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
name: CD Workflow
22

3-
on:
3+
on:
44
push:
5-
tags:
6-
- "services/[a-zA-Z]+/v[0-9]+.[0-9]+.[0-9]+*"
7-
- "core/v[0-9]+.[0-9]+.[0-9]+*"
8-
workflow_dispatch:
5+
branches:
6+
- main
97

108
jobs:
11-
main:
12-
name: Build & Publish module
13-
runs-on: "ubuntu-latest"
14-
steps:
15-
- name: Checkout
16-
uses: actions/checkout@v4
9+
check-version:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
fetch-depth: 0
1715
- name: Install Python
1816
uses: actions/setup-python@v5
1917
with:
20-
python-version: "3.8"
21-
- name: Extract updated module path
18+
python-version: "3.8"
19+
- name: Push tag for each updated package
2220
env:
23-
TAG: ${{ github.event.ref }}
24-
run: |
25-
# Remove the `refs/tags` prefix of the git tag
26-
TAG_NO_PREFIX=$(echo "$TAG" | sed 's/^refs\/tags\///')
27-
# Extract the path of the module to publish from the tag
28-
PACKAGE_PATH=$(echo "$TAG_NO_PREFIX" | rev | cut -d'/' -f2- | rev)
29-
# Save the path to the module for use in the build/publish step to only update the module associated with this tag
30-
echo "PACKAGE_PATH=$PACKAGE_PATH" >> $GITHUB_ENV
31-
- name: Build & Publish to PyPi
21+
GH_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
3222
run: |
23+
git config --global user.name "SDK Releaser Bot"
24+
git config --global user.email "[email protected]"
25+
3326
pip install poetry
34-
cd $PACKAGE_PATH
35-
poetry publish --build --username="__token__" --no-interaction --password="${{ secrets.PYPI_TOKEN }}"
27+
scripts/cd.sh
28+

.github/workflows/release-trigger.yaml

Lines changed: 0 additions & 28 deletions
This file was deleted.

scripts/trigger_script.sh renamed to scripts/cd.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ for file in $(git diff --name-only HEAD~1..HEAD | grep pyproject.toml); do
1010
if git rev-parse --verify $expected_tag^{tag} &> /dev/null; then
1111
echo "Tag '$expected_tag' already exists."
1212
else
13+
# Tag doesn't exist. Create tag and build/publish to PyPi
1314
echo "Tag '$expected_tag' does not exist. Creating new tag to trigger release."
1415
git tag -a $expected_tag -m "Release $version"
1516
git push origin tag $expected_tag
17+
poetry publish --build --username="__token__" --no-interaction --password="${{ secrets.PYPI_TOKEN }}"
1618
fi
1719
done

0 commit comments

Comments
 (0)