Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Further automate CD (#1005)
Browse files Browse the repository at this point in the history
* ✨ Add workflow to detect new version & push a tag on success

* πŸ”– Bump version

* 🚚 Renaming

* 🚚 Renaming v2

* πŸ› Fix tag

* πŸ“ Update release process

* πŸ“ Add links
  • Loading branch information
trymzet authored Aug 26, 2024
1 parent ac74a54 commit fc8796a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/detect-and-tag-new-version.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
28 changes: 15 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
Expand Down

0 comments on commit fc8796a

Please sign in to comment.