-
Notifications
You must be signed in to change notification settings - Fork 52
127 lines (112 loc) · 4.46 KB
/
cd.yml
File metadata and controls
127 lines (112 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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