Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
build-for-release.yml 3.03 KiB
name: Release 1 - Build Release Artifact
run-name: Build ${{ inputs.version }}

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:
  check-version:
    runs-on: ubuntu-22.04
    timeout-minutes: 10
    outputs:
      ee: ${{ fromJson(steps.canonical_version.outputs.result).ee }}
      oss: ${{ fromJson(steps.canonical_version.outputs.result).oss }}
    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
    - uses: actions/checkout@v3
      with:
        sparse-checkout: release
    - name: Prepare build scripts
      run: cd ${{ github.workspace }}/release && yarn && yarn build
    - name: Get Release Version
      uses: actions/github-script@v6
      id: canonical_version
      with:
        script: |
          const { isValidVersionString, getCanonicalVersion } = require('${{ github.workspace }}/release/dist/index.cjs');

          const version = '${{ inputs.version }}';

          if (!isValidVersionString(version)) {
            throw new Error("The version format is invalid! It must start with either 'v0.' or 'v1.'.");
          }

          return {
            ee: getCanonicalVersion(version, 'ee'),
            oss: getCanonicalVersion(version, 'oss'),
          };

  build-uberjar-for-release:
    needs: check-version
    runs-on: ubuntu-22.04
    timeout-minutes: 50
    strategy:
      matrix:
        edition: [oss, ee]
    env:
      INTERACTIVE: false
    steps:
    - 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