-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (107 loc) · 3.91 KB
/
draft-release.yaml
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
128
name: Draft release
on:
workflow_dispatch:
inputs:
versionBump:
description: "Version bump"
type: choice
required: true
default: "patch"
options:
- patch
- minor
- major
- exact-version
exactVersion:
description: 'Exact version: (Only effective selecting "exact-version" as version bump)'
required: false
permissions:
contents: write
jobs:
prepare-release:
name: "Prepare Release"
runs-on: ubuntu-latest
steps:
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
id: app-token
with:
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
cache: "gradle"
- name: Determine Next Version
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
VERSION_BUMP=${{ github.event.inputs.versionBump }}
if [[ "$VERSION_BUMP" == "major" || "$VERSION_BUMP" == "minor" || "$VERSION_BUMP" == "patch" ]]; then
./gradlew --quiet --console=plain versionBump -Pmode="$VERSION_BUMP"
else
./gradlew --quiet --console=plain versionBump -PexactVersion="${{ github.event.inputs.exactVersion }}"
fi
NEXT_VERSION=$(./gradlew --quiet --console=plain getVersion)
echo "RELEASE_TAG=v${NEXT_VERSION}" >> "$GITHUB_ENV"
- name: Validate release tag
shell: bash
run: |
if [ -z "${RELEASE_TAG}" ]; then
echo "RELEASE_TAG is not set or is empty"
exit 1
fi
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then
echo "Error: Tag $RELEASE_TAG already existing"
echo "If you are trying to re-create a draft release with this version, please delete the release and the tag first."
echo "If this version has already been release consider using a different one."
exit 1
fi
- name: Verify Checks in main
run: |
./gradlew "mainStatus"
- name: Patch Plugin XML
run: |
./gradlew ":packages:jetbrains-plugin:patchPluginXml"
- name: Verify Plugin
run: |
./gradlew ":packages:jetbrains-plugin:verifyPlugin"
- name: Sign and Publish Plugin in Beta
env:
JB_PUBLISH_CHANNEL: "beta"
JB_PUBLISH_TOKEN: ${{ secrets.JB_PUBLISH_TOKEN }}
JB_CERTIFICATE_CHAIN: ${{ secrets.JB_CERTIFICATE_CHAIN }}
JB_PRIVATE_KEY: ${{ secrets.JB_PRIVATE_KEY }}
JB_PRIVATE_KEY_PASSWORD: ${{ secrets.JB_PRIVATE_KEY_PASSWORD }}
run: |
./gradlew ":packages:jetbrains-plugin:publishPlugin"
- name: Patch Changelog
run: |
./gradlew ":packages:jetbrains-plugin:patchChangelog"
- name: Create Draft Release
shell: bash
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
set -e
echo Creating draft release for: "${RELEASE_TAG}"
git add .
git commit --no-verify -m "Release ${RELEASE_TAG}"
git tag ${RELEASE_TAG}
git push origin ${RELEASE_TAG}
GIT_REF=$(git rev-parse ${RELEASE_TAG})
ls packages/jetbrains-plugin/build/distributions/jetbrains-plugin.zip
CHANGELOG=$(./gradlew --quiet --console=plain :packages:jetbrains-plugin:getChangelog)
gh release create "${RELEASE_TAG}" \
--title "${RELEASE_TAG}" \
--notes "${CHANGELOG}" \
--target "${GIT_REF}" \
--draft \
packages/jetbrains-plugin/build/distributions/jetbrains-plugin.zip