Skip to content

Commit

Permalink
Merge PR #237 (update CI/CD)
Browse files Browse the repository at this point in the history
and update HISTORY.md.

Pushing tags will create a draft release with build artifacts and
publish to test.pypi. Releasing the draft release will publish the
same artifacts to pypi.

closes #237, closes #235
  • Loading branch information
torik42 committed Nov 22, 2022
2 parents 484070e + f6c2e7b commit c69d634
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 44 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Build and prepare release

on:
push:
tags:
- '[1-9]+.[0-9]+.[0-9]+'
- '[1-9]+.[0-9]+.[0-9]+a[0-9]+'
- '[1-9]+.[0-9]+.[0-9]+b[0-9]+'
- '[1-9]+.[0-9]+.[0-9]+rc[0-9]+'

jobs:
build-n-publish:
name: Build and prepare release
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Compare git tag to pyproject version
run: |
version_pyproject=$(grep -Po 'version = "\K[^"]*' pyproject.toml)
version_gittag=${{github.ref_name}}
if [[ "${version_pyproject}" != "${version_gittag}" ]]; then
echo "Version from pyproject '${version_pyproject}' is not equal to git tag '${version_gittag}'";
exit 1;
fi
echo "version=$version_gittag" >> $GITHUB_ENV
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install pypa/build
run: >-
python -m
pip install
build
- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- name: Create Draft Release
id: create_release
uses: ncipollo/release-action@v1
with:
allowUpdates: true
artifacts: 'dist/yalafi*.whl,dist/yalafi*.tar.gz'
draft: true
name: Version ${{ env.version }}
body: "<!---\nUpdate and test the Link to the correct section!\nAdd release info if necessary.\n--->\nFor a complete changelog see [HISTORY.md](https://github.com/torik42/YaLafi/blob/master/HISTORY.md#version-)."
prerelease: false
token: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

sleep:
name: Wait two minutes for PyPI to be available
needs: build-n-publish
runs-on: ubuntu-latest
steps:
- name: Wait two minutes for PyPI to be available
run: sleep 120

testPyPI-install:
name: Test PyPI package
needs: [build-n-publish, sleep]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install pytest
run: python -m pip install pytest
- name: Test install from test.PyPI
run: |
version_gittag=${{github.ref_name}}
pip install -i https://test.pypi.org/simple/ yalafi==${version_gittag}
- name: Test import of packages
run: |
python -c "import yalafi"
python -c "import yalafi.shell"
- name: Checkout YaLafi
uses: actions/checkout@v3
- name: Test with module pytest
run: |
rm -rf yalafi
python -m pytest tests
28 changes: 28 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Publish to PyPI

on:
release:
types: [released]

jobs:
publish-to-pypi:
name: Publish Package to PyPI
env:
version: ${{ github.ref_name }}
runs-on: ubuntu-latest

steps:
- run: >
echo "Publishing version $version"
- name: Download Release Assets
uses: dsaltares/fetch-gh-release-asset@3942ce82f1192754cd487a86f03eef6eeb89b5da
with:
version: tags/${{ env.version }}
regex: true
file: yalafi-${{ env.version }}.*
target: assets/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: assets/
44 changes: 0 additions & 44 deletions .github/workflows/publish.yml

This file was deleted.

3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Work in progress
- added macros \\Glsxtrfull, \\glsxtrfull, \\Glsxtrlong, \\glsxtrlong, \\Glsxtrshort, \\glsxtrshort;
**thanks to @JulianGoeltz** (PR [#234](../../pull/234))
- CI tests: add test for successful local installation **thanks to @JulianGoeltz** (PR [#236](../../pull/236))
- CD: add GitHub action for CD **together with @JulianGoeltz** (PR [#237](../../pull/237))
- on new version tags: create draft releases, publish to `test.pypi`, and test installation from `test.pypi`
- on releases: publish the assets to PyPI

Version 1.3.1 (2022/08/04)
--------------------------
Expand Down

0 comments on commit c69d634

Please sign in to comment.