Skip to content

🔖 release v2.1.1 (#92) #12

🔖 release v2.1.1 (#92)

🔖 release v2.1.1 (#92) #12

Workflow file for this run

name: Publish package
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
defaults:
run:
shell: bash
permissions: read-all
jobs:
build-and-publish:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/sqlite3-to-mysql
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v3
- name: Compare package version with ref/tag
id: compare
run: |
set -e
VERSION=$(awk -F'"' '/__version__/ {print $2}' sqlite3_to_mysql/__init__.py)
TAG=${GITHUB_REF_NAME#v}
if [[ "$VERSION" != "$TAG" ]]; then
echo "Version in sqlite3_to_mysql/__version__.py ($VERSION) does not match tag ($TAG)"
exit 1
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up Python
id: setup_python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install build dependencies
id: install_build_dependencies
run: |
set -e
python3 -m pip install --upgrade pip
pip install build setuptools wheel
- name: Build a binary wheel and a source tarball
id: build
run: |
set -e
python3 -m build --sdist --wheel --outdir dist/ .
- name: Publish distribution package to Test PyPI
id: publish_test
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish distribution package to PyPI
id: publish
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
- name: Install pyproject-parser
id: install_pyproject_parser
run: |
set -e
pip install pyproject-parser[cli]
- name: Read project name from pyproject.toml
id: read_project_name
run: |
set -e
NAME=$(pyproject-parser info project.name -r | tr -d '"')
echo "NAME=$NAME" >> $GITHUB_ENV
- name: Create tag-specific CHANGELOG
id: create_changelog
run: |
set -e
CHANGELOG_PATH=$RUNNER_TEMP/CHANGELOG.md
awk '/^#[[:space:]].*/ { if (count == 1) exit; count++; print } count == 1 && !/^#[[:space:]].*/ { print }' CHANGELOG.md | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' > $CHANGELOG_PATH
echo -en "\n[https://pypi.org/project/$NAME/$VERSION/](https://pypi.org/project/$NAME/$VERSION/)" >> $CHANGELOG_PATH
echo "CHANGELOG_PATH=$CHANGELOG_PATH" >> $GITHUB_ENV
- name: Github Release
id: github_release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.VERSION }}
tag_name: ${{ github.ref }}
body_path: ${{ env.CHANGELOG_PATH }}
files: |
dist/*.whl
dist/*.tar.gz
- name: Cleanup
if: ${{ always() }}
run: |
rm -rf dist
rm -rf $CHANGELOG_PATH