Skip to content

Commit

Permalink
build: create releases with Release Please
Browse files Browse the repository at this point in the history
resolves #346
  • Loading branch information
fengelniederhammer committed May 8, 2024
1 parent f3ba6db commit 5f045e4
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.0.1"
}
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 1 addition & 0 deletions version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.1

0 comments on commit 5f045e4

Please sign in to comment.