From fc8796a0b6773f859bc8100f6b643b7f2802a278 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zawadzki?= Date: Mon, 26 Aug 2024 19:07:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Further=20a?= =?UTF-8?q?utomate=20CD=20(#1005)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ Add workflow to detect new version & push a tag on success * 🔖 Bump version * 🚚 Renaming * 🚚 Renaming v2 * 🐛 Fix tag * 📝 Update release process * 📝 Add links --- .../workflows/detect-and-tag-new-version.yml | 43 +++++++++++++++++++ CONTRIBUTING.md | 28 ++++++------ pyproject.toml | 2 +- 3 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/detect-and-tag-new-version.yml diff --git a/.github/workflows/detect-and-tag-new-version.yml b/.github/workflows/detect-and-tag-new-version.yml new file mode 100644 index 000000000..5595bc353 --- /dev/null +++ b/.github/workflows/detect-and-tag-new-version.yml @@ -0,0 +1,43 @@ +# Detect if package version has been bumped & if so, trigger a release. + +# Take the version from pyproject.toml and check if a git tag for this version exists. +# If not, trigger the release worfklow (cd.yml) by pushing a new tag to the repository. + +name: Detect and tag new version + +on: + push: + branches: + - "2.0" + + workflow_dispatch: + +jobs: + check-version-and-push-tag: + name: Detect and create a tag for new version + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Rye + uses: eifinger/setup-rye@v4 + + - name: Get package version from pyproject.toml + id: get-version + run: echo "version=$(rye version)" >> $GITHUB_OUTPUT + + - name: Check if a tag for this version already exists in the repo + uses: mukunku/tag-exists-action@v1.6.0 + id: check-tag + with: + tag: v${{ steps.get-version.outputs.version }} + + - name: Publish the new tag + # Trigger the cd.yml workflow if a new tag is detected. + if: steps.check-tag.outputs.exists != 'true' + run: | + git tag -a v${{ steps.get-version.outputs.version }} -m "Release v${{ steps.get-version.outputs.version }}" + git push origin v${{ steps.get-version.outputs.version }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c3c2b243..fca5d48e2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -134,21 +134,13 @@ This will update the version in `pyproject.toml` accordingly. #### Release -Once the new version PR is merged to `2.0`, publish a version tag: - -```bash -viadot_version=v2.1.0 -git switch 2.0 && \ - git pull && \ - git tag -a $viadot_version -m "Release $viadot_version" && \ - git push origin $viadot_version -``` +Once the modified `pyproject.toml` is merged to `2.0`, a version tag will be [automatically created](https://github.com/dyvenia/viadot/blob/2.0/.github/workflows/detect-and-tag-new-version.yml), and the [release workflow](https://github.com/dyvenia/viadot/blob/2.0/.github/workflows/cd.yml) will be triggered. -Pushing the tag will trigger the release workflow, which will: +The release workflow will: -- create a release on GitHub -- publish the package to PyPI -- publish Docker images to ghcr.io +- create a [release](https://github.com/dyvenia/viadot/releases) on GitHub with auto-generated changelog +- publish [the package](https://pypi.org/project/viadot2/) to PyPI +- publish [Docker images](https://github.com/orgs/dyvenia/packages?repo_name=viadot) to ghcr.io ### Running actions @@ -163,3 +155,13 @@ If you need to pass parameters to the workflow, you can do so with the `--json` ```console echo '{"name":"scully", "greeting":"hello"}' | gh workflow run workflow.yml --json ``` + +### Developing & debugging actions + +To works on actions, you can use [act](https://github.com/nektos/act). + +```console +act -W .github/workflows/detect-and-tag-new-version.yml -s GITHUB_TOKEN="$(gh auth token)" +``` + +**NOTE** for actions that implicitly `{{ github.token }}`, you need to pass your token as the `GITHUB_TOKEN` act secret, as shown in the example above. diff --git a/pyproject.toml b/pyproject.toml index d889426e0..7925fbe8e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "viadot2" -version = "2.1.6" +version = "2.1.7" description = "A simple data ingestion library to guide data flows from some places to other places." authors = [ { name = "acivitillo", email = "acivitillo@dyvenia.com" },