🔖 release v2.5.0 #38
Workflow file for this run
This file contains hidden or 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: Publish package | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+*' | |
defaults: | |
run: | |
shell: bash | |
permissions: read-all | |
env: | |
NAME: mysql-to-sqlite3 | |
jobs: | |
test: | |
uses: ./.github/workflows/test.yml | |
secrets: inherit | |
publish: | |
needs: test | |
name: "Publish" | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/${{ env.NAME }} | |
permissions: | |
id-token: write | |
contents: write | |
concurrency: | |
group: publish-${{ github.ref }} | |
cancel-in-progress: false | |
steps: | |
- uses: actions/checkout@v5 | |
- name: Compare package version with ref/tag | |
id: compare | |
run: | | |
set -e | |
VERSION=$(awk -F'"' '/__version__/ {print $2}' src/mysql_to_sqlite3/__init__.py) | |
TAG=${GITHUB_REF_NAME#v} | |
if [[ "$VERSION" != "$TAG" ]]; then | |
echo "Version in src/mysql_to_sqlite3/__init__.py ($VERSION) does not match tag ($TAG)" | |
exit 1 | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Check CHANGELOG.md | |
id: check_changelog | |
run: | | |
set -e | |
if ! grep -q "# $VERSION" CHANGELOG.md; then | |
echo "CHANGELOG.md does not contain a section for $VERSION" | |
exit 1 | |
fi | |
- name: Set up Python | |
id: setup_python | |
uses: actions/setup-python@v6 | |
with: | |
python-version: "3.x" | |
cache: "pip" | |
- name: Install build dependencies | |
id: install_build_dependencies | |
run: | | |
set -e | |
python3 -m pip install -U pip | |
python3 -m pip install -U build | |
- name: Build a binary wheel and a source tarball | |
id: build | |
run: | | |
set -e | |
python3 -m build --sdist --wheel --outdir dist/ . | |
- name: Verify package metadata (twine) | |
id: twine_check | |
run: | | |
set -e | |
python3 -m pip install -U twine | |
twine check dist/* | |
- name: Ensure py.typed is packaged | |
id: assert_py_typed | |
run: | | |
set -e | |
unzip -l dist/*.whl | grep -q 'mysql_to_sqlite3/py.typed' | |
- name: Publish distribution package to PyPI | |
id: publish | |
if: startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
- 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@v2 | |
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 | |
docker: | |
needs: [ test, publish ] | |
permissions: | |
packages: write | |
contents: read | |
uses: ./.github/workflows/docker.yml | |
secrets: inherit | |
docs: | |
uses: ./.github/workflows/docs.yml | |
needs: [ test, publish ] | |
permissions: | |
contents: write | |
secrets: inherit |