-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/dei 176 automated container publish to ghcr (#113)
* Create main.yml Signed-off-by: CindyvdVries <[email protected]> * Update and rename main.yml to docker_image.yml Signed-off-by: CindyvdVries <[email protected]> * Update docker_image.yml * Update docker_image.yml * spaces * get versions for tags * spaces * test * Update setup_environment.yml * Update docker_image.yml * Update docker_image.yml * Update docker_image.yml * token not given as input when calling workflow * Update docker_image.yml * Update docker_image.yml * a space... * Update docker_image.yml * Update docker_image.yml * another test * does this work.. * right tags * syntax * Update docker_image.yml * lowercase and remove metadata action * clean up workflows * create seperate version_upgrade workflow * change on event for testing purposes * testing.. * Update bump_version.yml * passing secrets to workflow_call * wrong file * Update version_upgrade.yml * passs env vars through * yet again spaces * passing env vars * spaces.. * with? * another try * test again * typisch * Update version_upgrade.yml * bump patch version: 0.3.13 * bump patch version: 0.3.14 * bump patch version: 0.3.15 * bump patch version: 0.3.16 * bump patch version: 0.3.17 * bump patch version: 0.3.18 * Update bump_version.yml * clean up * reset version * Update release.yml * bump minor version: 0.4.0 * Update version_upgrade.yml * bump minor version: 0.5.0 * Update release.yml * bump minor version: 0.6.0 * Update version_upgrade.yml * bump minor version: 0.7.0 * seperate creating documentation workflow * bump minor version: 0.8.0 * remove poetry install * bump minor version: 0.9.0 * Update mkdocs_documentation.yml * bump minor version: 0.10.0 * bump minor version: 0.11.0 * one more try * bump minor version: 0.4.0 * one more try * bump minor version: 0.5.0 * reset version * bump minor version: 0.4.0 * login for mike deploy * reset version * bump minor version: 0.4.0 * update from feedback comments * bump minor version: 0.4.0 * bump minor version: 0.5.0 * Update release.yml Signed-off-by: CindyvdVries <[email protected]> * bump major version: 1.0.0 * pass project version through for latest * bump major version: 2.0.0 * if no project_version defined * bump major version: 3.0.0 * setting project_version * bump minor version: 3.1.0 * bump minor version: 3.2.0 * set version back * Update with review feedback * bump minor version: 0.4.0 * reset version * bump minor version: 0.4.0 * bump minor version: 0.5.0 --------- Signed-off-by: CindyvdVries <[email protected]> Co-authored-by: github-actions <[email protected]>
- Loading branch information
1 parent
bed8edc
commit 6969d4b
Showing
7 changed files
with
181 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Bump a patch version with poetry when a pull requst is merged | ||
|
||
name: bump patch version using poetry | ||
|
||
on: | ||
|
@@ -9,32 +11,8 @@ on: | |
|
||
jobs: | ||
bump-up-version: | ||
runs-on: ubuntu-latest | ||
if: github.event.pull_request.merged == true | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.VERSION_DECOIMPACT }} | ||
- name: install python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: 1.4.2 | ||
- name: bump version and update template_input.yaml | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
poetry version patch | ||
PROJECT_VERSION=$(poetry version --short) | ||
sed -i "1 s/.*/version: $PROJECT_VERSION/" template_input.yaml | ||
- name: commit changes | ||
run: | | ||
PROJECT_VERSION=$(poetry version --short) | ||
git add template_input.yaml | ||
git add pyproject.toml | ||
git commit -m "bump patch version: $PROJECT_VERSION" | ||
git push | ||
secrets: inherit | ||
uses: ./.github/workflows/version_upgrade.yml | ||
with: | ||
release_type: patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# This workflow should be triggered when a release is done (workflow_call) | ||
# And also need to be able to run manually (workflow_dispatch). It uses | ||
# the current version from poetry as a tag for the docker container and | ||
# pushes the container to the GitHub Container Registry | ||
# (ghcr.io/deltares/d-ecoimpact:latest). | ||
|
||
name: "Publish to GHCR" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
project_version: | ||
required: true | ||
default: false | ||
type: string | ||
workflow_dispatch: | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Convert Deltares/D-EcoImpact to deltares/d-ecoimpact because | ||
# image name can't support uppercase | ||
- name: downcase REPO | ||
run: | | ||
echo "IMAGE_NAME=${IMAGE_NAME,,}" >>${GITHUB_ENV} | ||
- name: checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.VERSION_DECOIMPACT || github.token }} | ||
fetch-depth: 0 | ||
- name: install python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: 1.4.2 | ||
- name: Get current version | ||
id: get-version | ||
if: ${{ env.PROJECT_VERSION }} == false | ||
run: | | ||
PROJECT_VERSION=$(poetry version --short) | ||
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_OUTPUT | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push the Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: | | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | ||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.project_version || steps.get-version.outputs.PROJECT_VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Create Mkdocs documentation | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
project_version: | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
create-docs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.VERSION_DECOIMPACT }} | ||
fetch-depth: 0 | ||
- name: install python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: 1.4.2 | ||
- name: Install Dependencies | ||
run: poetry install | ||
- name: Create new version of mkdocs and publish | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
poetry run mike deploy --push --update-aliases ${{ inputs.project_version }} latest | ||
poetry run mike set-default --push latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# This workflow should be triggered when a release of the main is needed. | ||
# It creates a tag and regenerates the documentation to generate a release. | ||
# It does not bump the version number, that happens for the merged pull request. | ||
# This workflow should be triggered when a release of the main is needed. | ||
# It creates a tag and regenerates the documentation to generate a release. | ||
|
||
name: Release major or minor version (create tag and documentation) | ||
|
||
|
@@ -16,49 +15,35 @@ on: | |
- major | ||
|
||
jobs: | ||
bump-up-version: | ||
secrets: inherit | ||
uses: ./.github/workflows/version_upgrade.yml | ||
with: | ||
release_type: ${{ github.event.inputs.release_type }} | ||
|
||
create-release: | ||
runs-on: ubuntu-latest | ||
needs: bump-up-version | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.VERSION_DECOIMPACT }} | ||
fetch-depth: 0 | ||
- name: install python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: 1.4.2 | ||
- name: bump version and update template_input.yaml | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
poetry version ${{ github.event.inputs.release_type }} | ||
PROJECT_VERSION=$(poetry version --short) | ||
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV | ||
sed -i "1 s/.*/version: $PROJECT_VERSION/" template_input.yaml | ||
- name: commit changes | ||
run: | | ||
PROJECT_VERSION=$(poetry version --short) | ||
git add template_input.yaml | ||
git add pyproject.toml | ||
git commit -m "bump version: $PROJECT_VERSION" | ||
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 }} | ||
tag_name: ${{ needs.bump-up-version.outputs.project_version }} | ||
release_name: Release ${{ needs.bump-up-version.outputs.project_version }} | ||
draft: false | ||
prerelease: false | ||
- name: Install Dependencies | ||
run: poetry install | ||
- name: Create new version of mkdocs and publish | ||
run: | | ||
poetry run mike deploy --push --update-aliases ${PROJECT_VERSION} latest | ||
poetry run mike set-default --push latest | ||
|
||
create-documentation: | ||
needs: bump-up-version | ||
secrets: inherit | ||
uses: ./.github/workflows/mkdocs_documentation.yml | ||
with: | ||
project_version: ${{ needs.bump-up-version.outputs.project_version }} | ||
|
||
docker-build: | ||
needs: bump-up-version | ||
uses: ./.github/workflows/docker_image.yml | ||
with: | ||
project_version: ${{ needs.bump-up-version.outputs.project_version }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# This workflow is used in bump_version and release workflows. It | ||
# install poetry and updates the version of the code. It gives back | ||
# the new version which can be used in the consequent workflows. | ||
|
||
name: Version upgrade with poetry | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
release_type: | ||
required: true | ||
type: string | ||
outputs: | ||
project_version: | ||
value: ${{ jobs.upgrade-version.outputs.job_output_version}} | ||
|
||
|
||
jobs: | ||
upgrade-version: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
job_output_version: ${{ steps.get-version.outputs.PROJECT_VERSION}} | ||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.VERSION_DECOIMPACT }} | ||
fetch-depth: 0 | ||
- name: install python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
- name: Install poetry | ||
uses: abatilo/actions-poetry@v2 | ||
with: | ||
poetry-version: 1.4.2 | ||
- name: bump version and update template_input.yaml | ||
id: get-version | ||
run: | | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
poetry version ${{ inputs.release_type }} | ||
PROJECT_VERSION=$(poetry version --short) | ||
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_OUTPUT | ||
sed -i "1 s/.*/version: $PROJECT_VERSION/" template_input.yaml | ||
- name: commit changes | ||
run: | | ||
PROJECT_VERSION=$(poetry version --short) | ||
git add template_input.yaml | ||
git add pyproject.toml | ||
git commit -m "bump ${{ inputs.release_type }} version: ${{ steps.get-version.outputs.PROJECT_VERSION }}" | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version: 0.3.14 | ||
version: 0.5.0 | ||
|
||
input-data: | ||
- dataset: | ||
|