From 848c26d2fe35cf2c15d89c27332a5f6971456473 Mon Sep 17 00:00:00 2001 From: FNTwin Date: Tue, 24 Sep 2024 13:09:38 -0400 Subject: [PATCH 1/3] [skip ci] gh release action --- .github/workflows/release.yaml | 134 +++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..7228d89 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,134 @@ +name: release + +on: + workflow_dispatch: + inputs: + release-version: + description: "A valid Semver version string" + required: true + +permissions: + contents: write + pull-requests: write + +jobs: + release: + # Do not release if not triggered from the default branch + if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + + runs-on: ubuntu-latest + timeout-minutes: 30 + + defaults: + run: + shell: bash -l {0} + + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: '3.11' + cache: pip + + #- name: Install requirements + # run: | + # pip install -U pip + # pip install .[dev] + + + - name: Check the version is valid semver + run: | + RELEASE_VERSION="${{ inputs.release-version }}" + + { + pysemver check $RELEASE_VERSION + } || { + echo "The version '$RELEASE_VERSION' is not a valid Semver version string." + echo "Please use a valid semver version string. More details at https://semver.org/" + echo "The release process is aborted." + exit 1 + } + + - name: Check the version is higher than the latest one + run: | + # Retrieve the git tags first + git fetch --prune --unshallow --tags &> /dev/null + + RELEASE_VERSION="${{ inputs.release-version }}" + LATEST_VERSION=$(git describe --abbrev=0 --tags) + + IS_HIGHER_VERSION=$(pysemver compare $RELEASE_VERSION $LATEST_VERSION) + + if [ "$IS_HIGHER_VERSION" != "1" ]; then + echo "The version '$RELEASE_VERSION' is not higher than the latest version '$LATEST_VERSION'." + echo "The release process is aborted." + exit 1 + fi + + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v4 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + toTag: "main" + + - name: Configure git + run: | + git config --global user.name "${GITHUB_ACTOR}" + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + + - name: Create and push git tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Tag the release + git tag -a "${{ inputs.release-version }}" -m "Release version ${{ inputs.release-version }}" + + # Checkout the git tag + git checkout "${{ inputs.release-version }}" + + # Push the modified changelogs + git push origin main + + # Push the tags + git push origin "${{ inputs.release-version }}" + + - name: Install library + run: | + pip install -U pip + python -m pip install --no-deps . + + - name: Build the wheel and sdist + run: python -m build --no-isolation + + #- name: Publish package to PyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # password: ${{ secrets.PYPI_API_TOKEN }} + # packages-dir: dist/ + + - name: Create GitHub Release + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 + with: + tag_name: ${{ inputs.release-version }} + body: ${{steps.github_release.outputs.changelog}} + + - name: Build book + run: | + jupyter-book build docs + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + path: "docs/_build/html" + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 \ No newline at end of file From 280450ac7ac0b02a53ef5231d11502d24f47ad0b Mon Sep 17 00:00:00 2001 From: FNTwin Date: Tue, 24 Sep 2024 13:11:21 -0400 Subject: [PATCH 2/3] [skip ci] enabled release --- .github/workflows/release.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 7228d89..6aafe32 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -105,11 +105,11 @@ jobs: - name: Build the wheel and sdist run: python -m build --no-isolation - #- name: Publish package to PyPI - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # password: ${{ secrets.PYPI_API_TOKEN }} - # packages-dir: dist/ + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + packages-dir: dist/ - name: Create GitHub Release uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 From d6783543251ee06319638bdccda77eaffab6e4c1 Mon Sep 17 00:00:00 2001 From: Cristian Gabellini <30401800+FNTwin@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:58:19 -0400 Subject: [PATCH 3/3] [skip ci] Disable push to pypi for testing --- .github/workflows/release.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6aafe32..ba08e51 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -105,11 +105,11 @@ jobs: - name: Build the wheel and sdist run: python -m build --no-isolation - - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_API_TOKEN }} - packages-dir: dist/ + #- name: Publish package to PyPI + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # password: ${{ secrets.PYPI_API_TOKEN }} + # packages-dir: dist/ - name: Create GitHub Release uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 @@ -131,4 +131,4 @@ jobs: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 \ No newline at end of file + uses: actions/deploy-pages@v2