From 628c17f04c645a2583236c02d99b292ec1adc76e Mon Sep 17 00:00:00 2001 From: Fabian Engelniederhammer Date: Tue, 7 May 2024 15:26:34 +0200 Subject: [PATCH] build: create releases with Release Please resolves #346 --- .github/workflows/release.yml | 61 +++++++++++++++++++++++++++++++++++ .release-please-manifest.json | 3 ++ README.md | 18 ++++++++++- release-please-config.json | 9 ++++++ version.txt | 1 + 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json create mode 100644 version.txt diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..e5ff938e0 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,61 @@ +name: Release SILO + +on: + workflow_run: + workflows: [LAPIS-SILO] + types: [completed] + branches: [main] + +env: + DOCKER_IMAGE_NAME: ghcr.io/genspectrum/lapis-silo + +jobs: + release-please: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + packages: write + if: ${{ github.event.workflow_run.conclusion == 'success' && github.repository == 'GenSpectrum/LAPIS-SILO' }} + steps: + - uses: google-github-actions/release-please-action@v4 + id: release + with: + path: . + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + target-branch: main + + - name: Inspect Release Outputs + run: | + cat <<'EOF' + ${{ toJson(steps.release.outputs) }} + EOF + + - uses: actions/checkout@v4 + if: ${{ steps.release.outputs.release_created }} + + - name: Set up Docker Buildx + if: ${{ steps.release.outputs.release_created }} + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + if: ${{ steps.release.outputs.release_created }} + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Tag Already Built Images With Release Tags + if: ${{ steps.release.outputs.release_created }} + run: | + MAJOR=${{ steps.release.outputs.major }} + MINOR=${{ steps.release.outputs.minor }} + PATCH=${{ steps.release.outputs.patch }} + TAGS=("$MAJOR.$MINOR" "$MAJOR.$MINOR.$PATCH") + # TODO (#405) include $MAJOR only for releases >= 1.0 + # TAGS=("$MAJOR" "$MAJOR.$MINOR" "$MAJOR.$MINOR.$PATCH") + for TAG in "${TAGS[@]}"; do + docker buildx imagetools create --tag $DOCKER_IMAGE_NAME:$TAG $DOCKER_IMAGE_NAME:latest + done diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 000000000..b7888c913 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.1" +} diff --git a/README.md b/README.md index 533abfea8..d9f5d8ac7 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ docker run The directory where SILO expects the preprocessing output can be overwritten via `silo --api --dataDirectory=/custom/data/directory` or in a corresponding -configuration [configuration file](#configuration-files). +[configuration file](#configuration-files). ### Notes On Building The Image @@ -141,6 +141,22 @@ Docker will cache layers, and it will cache the dependencies built by Conan via However, cache mounts don't work in GitHub Actions (https://github.com/docker/build-push-action/issues/716), so there we only rely on Docker's layer cache via Docker's gha cache backend. +## Creating A Release + +This project uses [Release Please](https://github.com/google-github-actions/release-please-action) to generate releases. +On every commit on the `main` branch, it will update a Pull Request with a changelog. +When the PR is merged, the release will be created. +Creating a release means: + +* A new Git tag is created. +* The Docker images of SILO are tagged with the new version. + * Suppose the created version is `2.4.5`, then it creates the tags `2`, `2.4` and `2.4.5` on the current `latest` image. + +The changelog and the version number are determined by the commit messages. +Therefore, commit messages should follow the [Conventional Commits](https://www.conventionalcommits.org/) specification. +Also refer to the Release Please documentation for more information on how to write commit messages +or see [Conventional Commits](#conventional-commits) below. + # Testing ## Unit Tests diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 000000000..cccd4b755 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,9 @@ +{ + "packages": { + ".": { + "release-type": "simple" + } + }, + "bump-minor-pre-major": true, + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" +} diff --git a/version.txt b/version.txt new file mode 100644 index 000000000..8a9ecc2ea --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.0.1 \ No newline at end of file