-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ci): solve the problem that tag made by workflow cannot trigger
- Loading branch information
Tomas Peterka
committed
Feb 8, 2024
1 parent
1361967
commit 962240a
Showing
2 changed files
with
27 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,54 @@ | ||
name: "[auto] release-python" | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
workflow_run: | ||
workflows: ["Release"] | ||
types: | ||
- completed | ||
|
||
env: | ||
PYTHON_VERSION: "3.10" | ||
|
||
jobs: | ||
build: | ||
release: | ||
name: Release new version to PyPI | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-tags: 'true' | ||
|
||
- name: Check version format vMAJOR.MINOR.PATCH(-SUFFIX) | ||
run: | | ||
if [[ ! "$GITHUB_REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$ ]]; then | ||
echo "Invalid version format. Expected vMAJOR.MINOR.PATCH(-SUFFIX)?, got ${GITHUB_REF_NAME}" | ||
RELEASE_TAG=$(git tag --points-at HEAD) | ||
echo "RELEASE_TAG: $RELEASE_TAG" | ||
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)*)?$ ]]; then | ||
echo "Invalid version format. Expected vMAJOR.MINOR.PATCH(-SUFFIX)?, got ${RELEASE_TAG}" | ||
exit 1 | ||
fi | ||
export VERSION="${RELEASE_TAG#v}" | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: check release tag exported | ||
run: | | ||
echo $VERSION | ||
exit 1 | ||
- name: Install the project | ||
- name: Release | ||
uses: dronetag/actions/release-python@main | ||
with: | ||
pypi_name: dronetag | ||
pypi_host: ${{ secrets.PRIV_PIP_HOST }} | ||
pypi_user: ${{ secrets.PRIV_PIP_USER }} | ||
pypi_pass: ${{ secrets.PRIV_PIP_PASSWORD }} | ||
version: "${GITHUB_REF_NAME#v}" | ||
version: "${VERSION}" | ||
|
||
- name: Commit version on release branch | ||
run: | | ||
if [[ $(git rev-parse heads/main) = $(git rev-parse ${GITHUB_REF}) ]]; then | ||
echo "We are at the top of main branch so we can commit the version bump" | ||
if [[ $(git rev-parse heads/main) = $(git rev-parse HEAD) ]]; then | ||
git checkout main | ||
sed -i "s/version = .*/version = \"${VERSION}\"/g" pyproject.toml | ||
git add pyproject.toml | ||
git commit -m "Release ${GITHUB_REF_NAME#v} [skip ci]" | ||
git commit -m "Release $VERSION [skip ci]" | ||
git push | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters