Skip to content

Commit

Permalink
Merge pull request #52 from Deltares/Feature/DEI-124-create-ga-for-ve…
Browse files Browse the repository at this point in the history
…rsioning

Feature/DEI-124: Create workflows for automatic minor/patch version update and manually trigger release
  • Loading branch information
mKlapwijk committed Oct 3, 2023
2 parents ec9628f + 2ada9aa commit 6781f8a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 1 deletion.
35 changes: 35 additions & 0 deletions .github/workflows/bump_poetry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Update Python Poetry packages

on:
push:
branches:
- main

env:
# The version type to update, based on the commit message (either patch for bug/fix or minor for all other commits)
VERSION_TYPE: ${{ (startsWith(github.event.head_commit.message, 'Fix') ||
startsWith(github.event.head_commit.message, 'fix') ||
startsWith(github.event.head_commit.message, 'Bug') ||
startsWith(github.event.head_commit.message, 'bug')) &&
'patch' || 'minor' }}

jobs:
update-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Run image
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.4.2
- name: bump up patch version
run: |
git config user.name github-actions
git config user.email github-actions@github.com
poetry version ${{ env.VERSION_TYPE }}
git add pyproject.toml
git commit -m "bump up ${{ env.VERSION_TYPE }} version from workflow"
git push
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow should be triggered when a release of the main is needed.
# It bumps the pyproject.toml version (major
# Using this version it creates a tag and a release

name: Release major version (create tag and bump poetry version)

on: workflow_dispatch

jobs:
update-packages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Run image
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.4.2
- name: bump up patch version
run: |
git config user.name github-actions
git config user.email github-actions@github.com
poetry version major
PROJECT_VERSION=$(poetry version)
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
git add pyproject.toml
git commit -m "bump up major version from release workflow"
git push
- name: Create Release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ env.PROJECT_VERSION }}
release_name: Release ${{ env.PROJECT_VERSION }}
draft: false
prerelease: false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,4 @@ dmypy.json
!tests_acceptance/input_yaml_files/*.yaml
!tests_acceptance/input_yaml_files/tables/*.yaml
/tests_acceptance/output_nc_files/*.nc
.idea/*
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ When adding a new dependency, do so using `poetry`
$ poetry add <package> --dev
```

### Versioning
- The repository depends on automatic versioning throuhg github actions and the commit message.
- If the commit message starts with `Fix`, `fix`, `Bug`, or `bug` the patch version will be increased in the
pyproject.toml and a tag will be created.

## Documentation

There are mkdocs available for documentation on how to use this code.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "decoimpact"
version = "0.1.0"
version = "0.4.0"
description = "A Python based kernel to perform spatial (environmental) impact assessment. Based on knowledge rules applied to model output and/or measurements."
authors = ["Deltares"]
readme = "README.md"
Expand Down

0 comments on commit 6781f8a

Please sign in to comment.