Skip to content
Snippets Groups Projects
Unverified Commit ca7d4341 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Add the official build for release workflow (#33362)

* Add the official build for release workflow

[ci skip]

* Store full-length SHA-1 commit hash in an artifact

* Trigger pre-release when the official build workflow finishes

* Download the official uberjar instead of building it again

* Adapt `check-commit` job to use the release artifact

* Adapt `check-uberjar-health` job to use the release artifact

* Adapt `run-sanity-check` job to use the release artifact

* Adapt `containerize` job to use the release artifact

* Adapt `verify-docker-pull` job to use the release artifact

[ci skip]

* Checkout the repo

We need the folder structure to satisfy the JAR path.
[ci skip]

* Make `check-uberjar-healt` dependend on the commit check job

* Fix commit-id file path

[ci skip]

* Fix `containerize` reference to the release artifact commit output

[ci skip]

* Fix `release-artifact` outputs

[ci skip]
parent 45df944e
Branches
Tags
No related merge requests found
name: Build for the official Metabase release
on:
workflow_dispatch:
inputs:
version:
description: 'Metabase version (e.g. v0.46.3)'
type: string
required: true
commit:
description: 'A full-length commit SHA-1 hash'
required: true
jobs:
build-uberjar-for-release:
if: ${{ github.repository }} != 'metabase/metabase'
runs-on: ubuntu-22.04
timeout-minutes: 40
strategy:
matrix:
edition: [oss, ee]
env:
INTERACTIVE: false
steps:
- name: Fail early on the incorrect version format
if: ${{ !(startsWith(inputs.version,'v0.') || startsWith(inputs.version,'v1.')) }}
run: |
echo "The version format is invalid!"
echo "It must start with either 'v0.' or 'v1.'."
echo "Please, try again."
exit 1
# EE is always v1.x.y, OSS is always v0.x.y
- name: Determine the canonical version
uses: actions/github-script@v6
id: canonical_version
env:
VERSION: ${{ inputs.version }}
EDITION: ${{ matrix.edition }}
with:
result-encoding: string
script: |
var canonical_version;
const ver = process.env.VERSION;
if (process.env.EDITION === "ee") {
canonical_version = ver.replace(/^v0\./, "v1."); // always e.g. v1.47.2
} else {
canonical_version = ver.replace(/^v1\./, "v0."); // always e.g. v0.45.6
}
console.log("The canonical version of this Metabase", process.env.EDITION, "edition is", canonical_version);
return canonical_version;
- name: Check out the code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit }}
- name: Prepare front-end environment
uses: ./.github/actions/prepare-frontend
- name: Prepare back-end environment
uses: ./.github/actions/prepare-backend
- name: Build Metabase ${{ steps.canonical_version.outputs.result }}
run: ./bin/build.sh :edition :${{ matrix.edition }} :version ${{ steps.canonical_version.outputs.result }}
- name: Store commit's SHA-1 hash
run: echo ${{ inputs.commit }} > COMMIT-ID
shell: bash
- name: Calculate SHA256 checksum
run: sha256sum ./target/uberjar/metabase.jar > SHA256.sum
shell: bash
- name: Upload JARs as artifact
uses: actions/upload-artifact@v3
with:
name: metabase-${{ matrix.edition }}-uberjar
path: |
./target/uberjar/metabase.jar
./COMMIT-ID
./SHA256.sum
name: Pre-release [WIP]
on:
workflow_dispatch:
inputs:
commit:
description: 'A full-length commit SHA-1 hash'
required: true
version:
description: 'Intended version (e.g. v0.46.3)'
required: true
workflow_run:
workflows: [Build for the official Metabase release]
types: [completed]
env:
MAX_HASH_LENGTH: 8
CUSTOM_REPO: ${{ secrets.CUSTOM_RELEASE_REPO }}
jobs:
release-artifact:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-22.04
timeout-minutes: 10
strategy:
matrix:
edition: [oss, ee]
outputs:
version: ${{ steps.version-properties.outputs.version }}
commit: ${{ steps.version-properties.outputs.commit }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download Metabase ${{ matrix.edition }} artifact
run: |
declare -a curlHeaders=('-H' "Accept: application/vnd.github+json" '-H' "Authorization: Bearer $GITHUB_TOKEN" '-H' "X-GitHub-Api-Version: 2022-11-28")
download_link=$(
curl -sL \
"${curlHeaders[@]}" \
"${{ github.event.workflow_run.artifacts_url }}" \
| jq -r --arg name "$ARTIFACT_NAME" '.artifacts[] | select(.name == $name) | .archive_download_url')
curl -sL "${curlHeaders[@]}" $download_link -o mb.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ARTIFACT_NAME: metabase-${{ matrix.edition }}-uberjar
- name: Unzip Metabase artifact containing an uberjar
run: unzip mb.zip
- name: Extract the version.properties file from the JAR
run: |
jar xf target/uberjar/metabase.jar version.properties
mv version.properties resources/
- name: Reveal Metabase ${{ matrix.edition }} properties
id: version-properties
run: |
echo "version=$(grep -o '^tag=.*' ./resources/version.properties | cut -d'=' -f2)" >> $GITHUB_OUTPUT
echo "commit=$(cat ./COMMIT-ID)" >> $GITHUB_OUTPUT
shell: bash
- name: Upload Metabase ${{ matrix.edition }} JAR as artifact
uses: actions/upload-artifact@v3
with:
name: metabase-${{ matrix.edition }}-uberjar
path: |
./target/uberjar/metabase.jar
./COMMIT-ID
./SHA256.sum
check-commit:
needs: release-artifact
runs-on: ubuntu-22.04
timeout-minutes: 10
steps:
- name: Ensure that the intended version (${{ github.event.inputs.version }}) was never released before
- name: Ensure that the intended version ($VERSION) was never released before
run: |
if [[ "${{ github.event.inputs.version }}" = v* ]]; then
echo "Checking if ${{ github.event.inputs.version }} conflicts with a past release..."
else
echo "ERROR: the intended version must start with 'v', e.g. 'v0.46.3."
echo "ABORT!"
exit -1
fi
echo "Checking if $VERSION conflicts with a past release..."
CANONICAL_REFS=https://github.com/metabase/metabase/archive/refs
URL=${CANONICAL_REFS}/tags/${{ github.event.inputs.version }}.zip
URL=${CANONICAL_REFS}/tags/$VERSION.zip
HTTP_CODE=$(curl -s -L -o /dev/null --head -w "%{HTTP_CODE}" ${URL})
if [[ $HTTP_CODE =~ "200" ]]; then
echo "ERROR: that version was already released in the past."
......@@ -46,6 +85,8 @@ jobs:
exit -1
fi
fi
env:
VERSION: ${{ needs.release-artifact.outputs.version }}
- name: Check out the code to verify the release branch
uses: actions/checkout@v3
......@@ -54,7 +95,7 @@ jobs:
- name: Ensure that the specified commit exists in the latest release branch
run: |
echo "Checking if the specified commit is in a release branch..."
COMMIT=${{ github.event.inputs.commit }}
git branch -a --contains $COMMIT > branches.txt
if [[ $(grep -c master branches.txt) =~ 1 ]]; then
echo "Found in master branch. ABORT!"
......@@ -70,63 +111,13 @@ jobs:
echo "ABORT!."
exit -1
fi
build:
if: ${{ github.repository }} != 'metabase/metabase'
runs-on: ubuntu-22.04
needs: check-commit
name: Build Metabase ${{ matrix.edition }} @${{ github.event.inputs.commit }}
timeout-minutes: 40
strategy:
matrix:
edition: [oss, ee]
env:
MB_EDITION: ${{ matrix.edition }}
INTERACTIVE: false
steps:
- name: Fail early if custom docker release repo is missing
if: ${{ env.CUSTOM_REPO == null }}
run: exit 1
- name: Check out the code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit }}
- name: Prepare front-end environment
uses: ./.github/actions/prepare-frontend
- name: Prepare back-end environment
uses: ./.github/actions/prepare-backend
with:
m2-cache-key: pre-release-build
- name: Determine the canonical version ## EE is always v1.x.y, OSS is always v0.x.y
uses: actions/github-script@v6
id: canonical_version
env:
INTENDED_VERSION: ${{ github.event.inputs.version }}
EDITION: ${{ matrix.edition }}
with:
result-encoding: string
script: |
var canonical_version;
const ver = process.env.INTENDED_VERSION;
if (process.env.EDITION === "ee") {
canonical_version = ver.replace(/^v0\./, "v1."); // always e.g. v1.47.2
} else {
canonical_version = ver.replace(/^v1\./, "v0."); // always e.g. v0.45.6
}
console.log("The canonical version of this", process.env.EDITION, "edition is", canonical_version);
return canonical_version;
- name: Build
run: ./bin/build.sh :edition :${{ matrix.edition }} :version ${{ steps.canonical_version.outputs.result }}
- name: Prepare uberjar artifact
uses: ./.github/actions/prepare-uberjar-artifact
COMMIT: ${{ needs.release-artifact.outputs.commit }}
check-uberjar-health:
needs: [release-artifact, check-commit]
runs-on: ubuntu-22.04
name: Is ${{ matrix.edition }} (java ${{ matrix.java-version }}) healthy?
needs: build
timeout-minutes: 10
strategy:
matrix:
......@@ -152,7 +143,7 @@ jobs:
run-sanity-check:
runs-on: ubuntu-22.04
timeout-minutes: 30
needs: check-uberjar-health
needs: [release-artifact, check-uberjar-health]
strategy:
matrix:
edition: [oss, ee]
......@@ -176,7 +167,7 @@ jobs:
- name: Check out the code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit }}
ref: ${{ needs.release-artifact.outputs.commit }}
- name: Prepare front-end environment
uses: ./.github/actions/prepare-frontend
- name: Prepare JDK 11
......@@ -211,8 +202,8 @@ jobs:
if-no-files-found: ignore
containerize:
needs: [release-artifact, run-sanity-check]
runs-on: ubuntu-22.04
needs: run-sanity-check
timeout-minutes: 15
strategy:
matrix:
......@@ -226,10 +217,10 @@ jobs:
- name: Check out the code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.commit }}
ref: ${{ needs.release-artifact.outputs.commit }}
- name: Truncate commit hash
run: |
commit_id=${{ github.event.inputs.commit }}
commit_id=${{ needs.release-artifact.outputs.commit }}
truncated_hash=${commit_id:0:${{ env.MAX_HASH_LENGTH }}}
echo "COMMIT_IDENTIFIER=$truncated_hash" >> $GITHUB_ENV
......@@ -280,7 +271,7 @@ jobs:
verify-docker-pull:
runs-on: ubuntu-22.04
needs: containerize
needs: [release-artifact, containerize]
timeout-minutes: 15
strategy:
matrix:
......@@ -288,7 +279,7 @@ jobs:
steps:
- name: Truncate commit hash
run: |
commit_id=${{ github.event.inputs.commit }}
commit_id=${{ needs.release-artifact.outputs.commit }}
truncated_hash=${commit_id:0:${{ env.MAX_HASH_LENGTH }}}
echo "COMMIT_IDENTIFIER=$truncated_hash" >> $GITHUB_ENV
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment