From 2fc9811c74a517fd4db85dabf0211a4712bb6630 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Tue, 16 Jun 2020 12:44:13 +0300 Subject: [PATCH] build(gha): Add automated CalVer releases (#539) --- .craft.yml | 1 + .env | 1 + .github/workflows/release.yml | 23 ++++++++++++++++++++--- docker-compose.yml | 8 ++++---- scripts/bump-version.sh | 12 +++++++++--- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/.craft.yml b/.craft.yml index ff71152..ad41cd8 100644 --- a/.craft.yml +++ b/.craft.yml @@ -2,6 +2,7 @@ minVersion: "0.10.0" github: owner: getsentry repo: onpremise +releaseBranchPrefix: releases changelogPolicy: none artifactProvider: name: none diff --git a/.env b/.env index b4f5273..aec59cb 100644 --- a/.env +++ b/.env @@ -1,3 +1,4 @@ COMPOSE_PROJECT_NAME=sentry_onpremise SENTRY_EVENT_RETENTION_DAYS=90 SENTRY_VERSION=latest +SYMBOLICATOR_VERSION=latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1fb717d..0a36cb3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,14 +1,31 @@ on: repository_dispatch: types: [release] + schedule: + # We want the release to be at 10 or 11am Pacific Time + # We also make this an hour after all others such as Sentry, + # Snuba, and Relay to make sure their releases finish. + - cron: '0 18 15 * *' jobs: release: runs-on: ubuntu-latest name: "Release a new version" steps: + - id: calver + if: ${{ !github.event.client_payload.version }} + run: echo "::set-output name=version::$(date +'%y.%-m.0')" - uses: actions/checkout@v2 - - uses: getsentry/craft-action@master + - uses: getsentry/craft@master with: action: prepare - version: ${{ github.event.client_payload.version }} - dry_run: ${{ github.event.client_payload.dry_run }} + version: ${{ github.event.client_payload.version || steps.calver.outputs.version }} + env: + DRY_RUN: ${{ github.event.client_payload.dry_run }} + - uses: getsentry/craft@master + with: + action: publish + version: ${{ github.event.client_payload.version || steps.calver.outputs.version }} + keep_branch: true + no_merge: true + env: + DRY_RUN: ${{ github.event.client_payload.dry_run }} diff --git a/docker-compose.yml b/docker-compose.yml index c10665a..c27cdbf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -133,7 +133,7 @@ services: command: '"*/5 * * * * gosu snuba snuba cleanup --dry-run False"' symbolicator: << : *restart_policy - image: 'getsentry/symbolicator:latest' + image: 'getsentry/symbolicator:$SYMBOLICATOR_VERSION' volumes: - 'sentry-symbolicator:/data' command: run @@ -143,7 +143,7 @@ services: build: context: ./cron args: - BASE_IMAGE: 'getsentry/symbolicator:latest' + BASE_IMAGE: 'getsentry/symbolicator:$SYMBOLICATOR_VERSION' command: '"55 23 * * * gosu symbolicator symbolicator cleanup"' volumes: - 'sentry-symbolicator:/data' @@ -174,7 +174,7 @@ services: << : *restart_policy ports: - '9000:80/tcp' - image: "nginx:1.16" + image: 'nginx:1.16' volumes: - type: bind read_only: true @@ -185,7 +185,7 @@ services: - relay relay: << : *restart_policy - image: "getsentry/relay:$SENTRY_VERSION" + image: 'getsentry/relay:$SENTRY_VERSION' volumes: - type: bind read_only: true diff --git a/scripts/bump-version.sh b/scripts/bump-version.sh index 2a197d8..081af99 100644 --- a/scripts/bump-version.sh +++ b/scripts/bump-version.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -eux +set -eu SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $SCRIPT_DIR/.. @@ -7,5 +7,11 @@ cd $SCRIPT_DIR/.. OLD_VERSION="$1" NEW_VERSION="$2" -VERSION=$2 -echo "New version: $VERSION" +SYMBOLICATOR_VERSION=$(curl -sSL 'https://api.github.com/repos/getsentry/symbolicator/git/refs/heads/master' | grep -Po '(?<=\"sha\": \")([a-f0-9]{5,40})(?=\",?)') + +sed -i -e "s/^SYMBOLICATOR_VERSION=.*\$/SYMBOLICATOR_VERSION=$SYMBOLICATOR_VERSION/" .env +sed -i -e "s/^SENTRY_VERSION=.*\$/SENTRY_VERSION=$NEW_VERSION/" .env +sed -i -e "s/^\# Sentry .* On-Premise/# Sentry $NEW_VERSION On-Premise/" README.md + +echo "New version: $NEW_VERSION" +echo "New Symbolicator version: $SYMBOLICATOR_VERSION"