data: bump latest known variables #281
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
name: Auto Release | |
on: | |
push: | |
branches: | |
- "master" | |
workflow_dispatch: | |
inputs: | |
bump-version: | |
description: 'Automatically increase patch version (true|false)' | |
default: 'true' | |
required: false | |
release-type: | |
description: 'Type of release (patch|minor|major)' | |
default: 'patch' | |
required: false | |
concurrency: | |
group: ${{ github.workflow }} | |
cancel-in-progress: true | |
env: | |
VERSION_FILE: oelint_adv/version.py | |
MODULE_CODE: oelint_adv/* | |
PYPI_PUBLISH: 1 | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
if: github.repository == 'priv-kweihmann/oelint-adv' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Sanity checks | |
run: | | |
if [ "${{ env.PYPI_PUBLISH }}" = "1" ] && [ -z "${{ secrets.PYPI_API_TOKEN }}" ]; then | |
echo "::error ::secrets.PYPI_API_TOKEN needs to be set for this action" | |
exit 1 | |
fi | |
if [ -z "${{ secrets.TOKEN }}" ]; then | |
echo "::error ::secrets.TOKEN needs to be set for this action" | |
exit 1 | |
fi | |
if [ "${{ github.event_name == 'workflow_dispatch' }}" = "true" ]; then | |
if [ -z "${{ github.event.inputs.release-type }}" ]; then | |
echo "::error ::release-type cannot be empty" | |
exit 1 | |
fi | |
fi | |
- name: Check if relevant for release | |
uses: dorny/[email protected] | |
id: code-changes | |
with: | |
filters: | | |
relevant-for-release: | |
- 'requirements.txt' | |
- '${{ env.MODULE_CODE }}' | |
- name: Check if we need to release | |
id: release-needed | |
run: | | |
do_release=0 | |
do_bump=0 | |
[ "${{ steps.code-changes.outputs.relevant-for-release == 'true' }}" = "true" ] && do_release=1 | |
if [ "${{ github.event_name == 'workflow_dispatch' }}" = "true" ]; then | |
do_release=1 | |
[ "${{ github.event.inputs.bump-version }}" = "true" ] && do_bump=1 | |
fi | |
if [ "${{ github.event_name == 'workflow_dispatch' }}" = "true" ]; then | |
echo RELEASE_TYPE="${{ github.event.inputs.release-type }}" >> $GITHUB_OUTPUT | |
else | |
echo RELEASE_TYPE="patch" >> $GITHUB_OUTPUT | |
fi | |
if [ $do_release -eq 1 ] || [ $do_bump -eq 1 ]; then | |
echo DO_RELEASE=true >> $GITHUB_OUTPUT | |
else | |
echo DO_RELEASE=false >> $GITHUB_OUTPUT | |
fi | |
- name: Install dependencies | |
if: steps.release-needed.outputs.DO_RELEASE == 'true' | |
run: | | |
python -m pip install --upgrade pip build | |
pip install -r requirements.txt | |
- name: Bump version | |
id: version-bump | |
run: | | |
pip install -r requirements-dev.txt | |
bump2version --list ${{ steps.release-needed.outputs.RELEASE_TYPE }} ${{ env.VERSION_FILE }} >> $GITHUB_OUTPUT | |
- name: Build | |
if: steps.release-needed.outputs.DO_RELEASE == 'true' | |
run: | | |
python -m build --sdist --wheel | |
- name: Commit new version | |
if: steps.release-needed.outputs.DO_RELEASE == 'true' | |
uses: actions-x/commit@v6 | |
with: | |
message: 'Release ${{ steps.version-bump.outputs.new_version }}' | |
- name: Create new release | |
if: steps.release-needed.outputs.DO_RELEASE == 'true' | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.version-bump.outputs.new_version }} | |
generateReleaseNotes: true | |
token: ${{ secrets.TOKEN }} | |
- name: Publish package | |
if: steps.release-needed.outputs.DO_RELEASE == 'true' && env.PYPI_PUBLISH == '1' | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |