Skip to content

ci: apply on master branch #111

ci: apply on master branch

ci: apply on master branch #111

---
name: Release development branches
on:
push:
branches:
- develop
- feat/*
- fix/*
- ci/*
jobs:
release:
runs-on: ubuntu-latest
outputs:
new_release_version: ${{ steps.version.outputs.new_release_version }}
new_release_published: ${{ steps.version.outputs.new_release_published }}
steps:
- uses: actions/checkout@v4
- name: Semantic Release Config
run: |
echo '{
"tagFormat":"${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/github"
]
}
'> .releaserc
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
branches: ${{ github.head_ref || github.ref_name }}
semantic_version: 21.1.1
extra_plugins: |
@semantic-release/[email protected]
@semantic-release/[email protected]
dry_run: true
ci: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Write in summary
run: |
echo "## Semantic Release" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "new_release_version: $NEW_RELEASE_VERSION" >> $GITHUB_STEP_SUMMARY
echo "new_release_published: $NEW_RELEASE_PUBLISHED" >> $GITHUB_STEP_SUMMARY
env:
NEW_RELEASE_VERSION: ${{ steps.semantic.outputs.new_release_version }}
NEW_RELEASE_PUBLISHED: ${{ steps.semantic.outputs.new_release_published }}
- name: Write in outputs
id: version
run: |
echo "NEW_RELEASE_VERSION=$NEW_RELEASE_VERSION" >> $GITHUB_OUTPUT
echo "NEW_RELEASE_PUBLISHED=$NEW_RELEASE_PUBLISHED" >> $GITHUB_OUTPUT
env:
NEW_RELEASE_VERSION: ${{ steps.semantic.outputs.new_release_version }}
NEW_RELEASE_PUBLISHED: ${{ steps.semantic.outputs.new_release_published }}
deploy:
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Update package version
id: update_version
run: |
sha_short=$(git rev-parse --short HEAD)
bump_version="${{ needs.release.outputs.new_release_version }}.dev${{ github.run_number }}"
echo "bump_version=$bump_version" >> $GITHUB_OUTPUT
echo "bump_version: $bump_version" >> $GITHUB_STEP_SUMMARY
echo $bump_version
poetry version $bump_version
- name: Build and publish
env:
PYPI_TEST_TOKEN: ${{ secrets.PYPI_TEST_TOKEN }}
run: |
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry config pypi-token.test-pypi $PYPI_TEST_TOKEN
poetry build
poetry publish -r test-pypi
if: needs.release.outputs.new_release_published == 'true'
- name: Clean PyPi release
if: always()
run: |
poetry add pypi-cleanup
poetry run pypi-cleanup --host https://test.pypi.org --username '__token__' --package libtado --do-it
env:
PYPI_CLEANUP_PASSWORD: ${{ secrets.PYPI_TEST_TOKEN }}