CD #207
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CD | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_type: | |
| description: 'Release type' | |
| required: true | |
| default: snapshot | |
| type: choice | |
| options: | |
| - snapshot | |
| - official | |
| permissions: | |
| contents: write | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| cache: sbt | |
| - name: Set up sbt | |
| uses: sbt/setup-sbt@v1 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Cache node_modules | |
| id: cache-node-modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: spark-ui/node_modules | |
| key: ${{ runner.os }}-node-modules-${{ hashFiles('spark-ui/package-lock.json') }} | |
| - name: Install npm dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: npm ci | |
| working-directory: ./spark-ui | |
| - name: Check branch for official release | |
| if: github.event.inputs.release_type == 'official' && github.ref != 'refs/heads/main' | |
| run: | | |
| echo "Official releases must be triggered from main, not $GITHUB_REF" | |
| exit 1 | |
| - name: Create release tag | |
| id: create-tag | |
| if: github.event.inputs.release_type == 'official' | |
| run: | | |
| VERSION=$(grep 'lazy val versionNum' build.sbt | grep -oE '"[0-9.]+"' | tr -d '"') | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git tag v${VERSION} | |
| git push origin v${VERSION} | |
| echo "IS_RELEASE=true" >> $GITHUB_ENV | |
| echo "tag=v${VERSION}" >> $GITHUB_OUTPUT | |
| working-directory: ./spark-plugin | |
| - name: Import GPG key | |
| if: github.event.inputs.release_type == 'official' | |
| run: echo "$PGP_SECRET" | base64 --decode | gpg --import --no-tty --batch --yes | |
| env: | |
| PGP_SECRET: ${{ secrets.PGP_SECRET }} | |
| - name: build frontend | |
| run: npm run deploy | |
| working-directory: ./spark-ui | |
| - name: package plugin | |
| run: sbt package | |
| working-directory: ./spark-plugin | |
| - name: publish to maven staging | |
| run: | | |
| if [[ "$IS_RELEASE" == "true" ]]; then | |
| export GITHUB_REF="refs/tags/${{ steps.create-tag.outputs.tag }}" | |
| fi | |
| sbt ci-release | |
| working-directory: ./spark-plugin | |
| env: | |
| PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} | |
| PGP_SECRET: ${{ secrets.PGP_SECRET }} | |
| SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} | |
| SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} | |
| - name: Create Release | |
| if: github.event.inputs.release_type == 'official' || startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| TAG="${{ steps.create-tag.outputs.tag || github.ref_name }}" | |
| VERSION="${TAG#v}" | |
| gh release create "$TAG" \ | |
| --title "Version $VERSION" \ | |
| --generate-notes \ | |
| --verify-tag | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Bump version | |
| if: github.event.inputs.release_type == 'official' || startsWith(github.ref, 'refs/tags/v') | |
| run: | | |
| VERSION=$(grep 'lazy val versionNum' build.sbt | grep -oE '"[0-9.]+"' | tr -d '"') | |
| NEW_VERSION=$(echo $VERSION | awk -F. '{$NF=$NF+1; print}' OFS='.') | |
| sed -i "s/lazy val versionNum: String = \"${VERSION}\"/lazy val versionNum: String = \"${NEW_VERSION}\"/" build.sbt | |
| sed -i "s/\"version\": \"${VERSION}\"/\"version\": \"${NEW_VERSION}\"/" ../spark-ui/package.json | |
| sed -i "s/${VERSION}/${NEW_VERSION}/g" clean-and-setup.sh | |
| OLD_README_VERSION=$(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' ../README.md | head -1) | |
| if [ -n "$OLD_README_VERSION" ] && [ "$OLD_README_VERSION" != "$VERSION" ]; then | |
| sed -i "s/${OLD_README_VERSION}/${VERSION}/g" ../README.md | |
| fi | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git config user.name "github-actions[bot]" | |
| git add build.sbt ../spark-ui/package.json clean-and-setup.sh ../README.md | |
| git commit -m "version bump to ${NEW_VERSION}" | |
| git push origin HEAD:main | |
| working-directory: ./spark-plugin |