From 7319ea2dcf9fa5089a26cfcb09fa7d69007ae3ce Mon Sep 17 00:00:00 2001 From: Jens L Date: Tue, 21 Jun 2022 23:31:27 +0200 Subject: [PATCH] ci: add version family (#3059) Signed-off-by: Jens Langhammer --- .bumpversion.cfg | 16 ++----------- .../action.yml | 14 +++++++++++ .github/workflows/ci-main.yml | 3 ++- .github/workflows/ci-outpost.yml | 3 ++- .github/workflows/release-publish.yml | 24 ++++++++++++++----- 5 files changed, 38 insertions(+), 22 deletions(-) rename .github/actions/{docker-setup => docker-push-variables}/action.yml (74%) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c5ebff303..8aef550c4 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -2,29 +2,17 @@ current_version = 2022.6.3 tag = True commit = True -parse = (?P\d+)\.(?P\d+)\.(?P\d+)\-?(?P.*) -serialize = - {major}.{minor}.{patch}-{release} - {major}.{minor}.{patch} +parse = (?P\d+)\.(?P\d+)\.(?P\d+) +serialize = {major}.{minor}.{patch} message = release: {new_version} tag_name = version/{new_version} -[bumpversion:part:release] -optional_value = stable -first_value = beta -values = - alpha - beta - stable - [bumpversion:file:pyproject.toml] [bumpversion:file:docker-compose.yml] [bumpversion:file:schema.yml] -[bumpversion:file:.github/workflows/release-publish.yml] - [bumpversion:file:authentik/__init__.py] [bumpversion:file:internal/constants/constants.go] diff --git a/.github/actions/docker-setup/action.yml b/.github/actions/docker-push-variables/action.yml similarity index 74% rename from .github/actions/docker-setup/action.yml rename to .github/actions/docker-push-variables/action.yml index bba66edab..008ca74e1 100644 --- a/.github/actions/docker-setup/action.yml +++ b/.github/actions/docker-push-variables/action.yml @@ -17,6 +17,12 @@ outputs: sha: description: "sha" value: ${{ steps.ev.outputs.sha }} + version: + description: "version" + value: ${{ steps.ev.outputs.version }} + versionFamily: + description: "versionFamily" + value: ${{ steps.ev.outputs.versionFamily }} runs: using: "composite" @@ -47,3 +53,11 @@ runs: print("##[set-output name=timestamp]%s" % int(time())) print("##[set-output name=sha]%s" % os.environ[sha]) print("##[set-output name=shouldBuild]%s" % should_build) + + import configparser + parser = configparser.ConfigParser() + parser.read(".bumpversion.cfg") + version = parser.get("bumpversion", "current_version") + version_family = ".".join(version.split(".")[:-1]) + print("##[set-output name=version]%s" % version) + print("##[set-output name=versionFamily]%s" % version_family) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 3354eba31..44a606f47 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -211,10 +211,10 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: prepare variables + uses: ./.github/actions/docker-push-variables id: ev env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - uses: ./.github/actions/docker-setup - name: Login to Container Registry uses: docker/login-action@v2 if: ${{ steps.ev.outputs.shouldBuild == 'true' }} @@ -231,4 +231,5 @@ jobs: ghcr.io/goauthentik/dev-server:gh-${{ steps.ev.outputs.branchNameContainer }}-${{ steps.ev.outputs.timestamp }}-${{ steps.ev.outputs.sha }} build-args: | GIT_BUILD_HASH=${{ steps.ev.outputs.sha }} + VERSION_FAMILY=${{ steps.ev.outputs.versionFamily }} platforms: ${{ matrix.arch }} diff --git a/.github/workflows/ci-outpost.yml b/.github/workflows/ci-outpost.yml index 1909f199b..b03c8ab76 100644 --- a/.github/workflows/ci-outpost.yml +++ b/.github/workflows/ci-outpost.yml @@ -67,8 +67,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: prepare variables + uses: ./.github/actions/docker-push-variables id: ev - uses: ./.github/actions/docker-setup env: DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - name: Login to Container Registry @@ -91,6 +91,7 @@ jobs: file: ${{ matrix.type }}.Dockerfile build-args: | GIT_BUILD_HASH=${{ steps.ev.outputs.sha }} + VERSION_FAMILY=${{ steps.ev.outputs.versionFamily }} platforms: ${{ matrix.arch }} build-outpost-binary: timeout-minutes: 120 diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml index 73ac030fa..93deba4de 100644 --- a/.github/workflows/release-publish.yml +++ b/.github/workflows/release-publish.yml @@ -5,7 +5,6 @@ on: types: [published, created] jobs: - # Build build-server: runs-on: ubuntu-latest steps: @@ -14,6 +13,9 @@ jobs: uses: docker/setup-qemu-action@v2.0.0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: prepare variables + uses: ./.github/actions/docker-push-variables + id: ev - name: Docker Login Registry uses: docker/login-action@v2 with: @@ -30,9 +32,11 @@ jobs: with: push: ${{ github.event_name == 'release' }} tags: | - beryju/authentik:2022.6.3, + beryju/authentik:${{ steps.ev.outputs.version }}, + beryju/authentik:${{ steps.ev.outputs.versionFamily }}, beryju/authentik:latest, - ghcr.io/goauthentik/server:2022.6.3, + ghcr.io/goauthentik/server:${{ steps.ev.outputs.version }}, + ghcr.io/goauthentik/server:${{ steps.ev.outputs.versionFamily }}, ghcr.io/goauthentik/server:latest platforms: linux/amd64,linux/arm64 context: . @@ -53,6 +57,9 @@ jobs: uses: docker/setup-qemu-action@v2.0.0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 + - name: prepare variables + uses: ./.github/actions/docker-push-variables + id: ev - name: Docker Login Registry uses: docker/login-action@v2 with: @@ -69,9 +76,11 @@ jobs: with: push: ${{ github.event_name == 'release' }} tags: | - beryju/authentik-${{ matrix.type }}:2022.6.3, + beryju/authentik-${{ matrix.type }}:${{ steps.ev.outputs.version }}, + beryju/authentik-${{ matrix.type }}:${{ steps.ev.outputs.versionFamily }}, beryju/authentik-${{ matrix.type }}:latest, - ghcr.io/goauthentik/${{ matrix.type }}:2022.6.3, + ghcr.io/goauthentik/${{ matrix.type }}:${{ steps.ev.outputs.version }}, + ghcr.io/goauthentik/${{ matrix.type }}:${{ steps.ev.outputs.versionFamily }}, ghcr.io/goauthentik/${{ matrix.type }}:latest file: ${{ matrix.type }}.Dockerfile platforms: linux/amd64,linux/arm64 @@ -138,6 +147,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: prepare variables + uses: ./.github/actions/docker-push-variables + id: ev - name: Get static files from docker image run: | docker pull ghcr.io/goauthentik/server:latest @@ -152,7 +164,7 @@ jobs: SENTRY_PROJECT: authentik SENTRY_URL: https://sentry.beryju.org with: - version: authentik@2022.6.3 + version: authentik@${{ steps.ev.outputs.version }} environment: beryjuorg-prod sourcemaps: './web/dist' url_prefix: '~/static/dist'