diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index e385efd3..29917830 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -31,7 +31,7 @@ jobs: run: tox -e py release: - name: mrack semantic release + name: mrack semantic release 🐕 runs-on: ubuntu-latest needs: [pre-commit, test] if: github.repository == 'neoave/mrack' @@ -58,8 +58,8 @@ jobs: fetch-depth: 0 - name: Get the new version using python-semantic-release run: | - pip3 install python-semantic-release==7.34.4 - echo "NEW_VERSION="`semantic-release print-version --noop` >> ${GITHUB_ENV} + pip3 install python-semantic-release==8.0.8 + echo "NEW_VERSION="`semantic-release version --print` >> ${GITHUB_ENV} - name: Update the mrack.spec changelog with initiator and basic message run: | # get the history of commits and generate changelog from it @@ -75,12 +75,70 @@ jobs: sed -ri \ "s/\%changelog/\%changelog\\n\*\ $TODAY\ $RELEASE_ACTOR\ -\ $NEW_VERSION-1/" \ mrack.spec + - name: Add version to specfile + run: | + export SPEC_VERSION_REGEX="s/^Version:(\s+)(.*)/Version:\1$NEW_VERSION/" + echo $SPEC_VERSION_REGEX + sed -i -E $SPEC_VERSION_REGEX mrack.spec - name: Add specfile to commit run: git add mrack.spec - name: Python Semantic Release - uses: relekang/python-semantic-release@v7.34.4 + uses: relekang/python-semantic-release@v8.0.8 with: github_token: ${{ secrets.TIBORIS_GH_TOKEN }} - pypi_token: ${{ secrets.PYPI_TOKEN }} + + copr-build: + name: Copr 📦 build for mrack + runs-on: ubuntu-latest + needs: [release] + steps: - name: Trigger COPR build run: curl -X POST ${{ secrets.COPR_WEBHOOK_URL }} + + python-build: + name: Build 🐍 distribution 📦 + runs-on: ubuntu-latest + needs: [release] + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: >- + Publish 🐍 distribution 📦 to PyPI + # only publish to PyPI on tag pushes + if: startsWith(github.ref, 'refs/tags/') + needs: [python-build] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/mrack/ + # IMPORTANT: mandatory for trusted publishing which is setup on pypi + permissions: + id-token: write + steps: + - name: Download all the dists from artifacts + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: list dist dir + run: ls -la dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/pyproject.toml b/pyproject.toml index 2c663cac..73b0ba0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,15 +15,11 @@ pythonpath = [ [tool.semantic_release] version_source = "commit" -commit_subject = "chore: Release version {version}" -commit_message = "Releasing mrack version {version}" -version_variable = [ +commit_message = "chore: Release version {version}\n\nReleasing new mrack version" +version_variables = [ "src/mrack/version.py:VERSION", "docs/conf.py:release", ] -version_pattern = [ - "mrack.spec:Version:\\s+{version}", -] branch = "main" commit = true tag = true