Skip to content

Commit ade2cf5

Browse files
authored
chore: CI/CD and basic infrastructure for the IntelliJ Plugin (#1)
1 parent 59c1f06 commit ade2cf5

38 files changed

+2077
-2
lines changed

Diff for: .github/PULL_REQUEST_TEMPLATE.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
^^^^^
3+
Please fill the title above according to https://www.conventionalcommits.org/en/v1.0.0/.
4+
5+
type(scope): message <TICKET-NUMBER-IF-ANY>
6+
7+
eg. fix(type-hint): infer type of a constant for type checking INTELLIJ-1111
8+
-->
9+
## Description
10+
<!--- Describe your changes in detail so reviewers have enough content on what this PR aims to achieve -->
11+
<!--- If applicable, describe (or illustrate) architecture flow -->
12+
13+
### Checklist
14+
- [ ] New tests and/or benchmarks are included.
15+
- [ ] Documentation is changed or added.
16+
- [ ] Changelog is updated accordingly.
17+
- [ ] I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement).
18+
19+
## Open Questions
20+
<!--- Any particular areas you'd like reviewers to pay attention to? -->

Diff for: .github/workflows/draft-release.yaml

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Draft release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
versionBump:
7+
description: 'Version bump'
8+
type: choice
9+
required: true
10+
default: 'patch'
11+
options:
12+
- patch
13+
- minor
14+
- major
15+
- exact-version
16+
17+
exactVersion:
18+
description: 'Exact version: (Only effective selecting "exact-version" as version bump)'
19+
required: false
20+
21+
permissions:
22+
contents: write
23+
24+
jobs:
25+
prepare-release:
26+
name: "Prepare Release"
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
- name: Setup JDK
34+
uses: actions/setup-java@v4
35+
with:
36+
distribution: 'adopt'
37+
java-version: '17'
38+
cache: 'gradle'
39+
- name: Determine Next Version
40+
shell: bash
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
set -e
45+
46+
VERSION_BUMP=${{ github.event.inputs.versionBump }}
47+
48+
if [[ "$VERSION_BUMP" == "major" || "$VERSION_BUMP" == "minor" || "$VERSION_BUMP" == "patch" ]]; then
49+
./gradlew --quiet --console=plain versionBump -Pmode="$VERSION_BUMP"
50+
else
51+
./gradlew --quiet --console=plain versionBump -PexactVersion="${{ github.event.inputs.exactVersion }}"
52+
fi
53+
54+
NEXT_VERSION=$(./gradlew --quiet --console=plain getVersion)
55+
echo "RELEASE_TAG=v${NEXT_VERSION}" >> "$GITHUB_ENV"
56+
57+
- name: Validate release tag
58+
shell: bash
59+
run: |
60+
if [ -z "${RELEASE_TAG}" ]; then
61+
echo "RELEASE_TAG is not set or is empty"
62+
exit 1
63+
fi
64+
65+
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then
66+
echo "Error: Tag $RELEASE_TAG already existing"
67+
echo "If you are trying to re-create a draft release with this version, please delete the release and the tag first."
68+
echo "If this version has already been release consider using a different one."
69+
exit 1
70+
fi
71+
72+
- name: Run All Tests
73+
run: |
74+
./gradlew "unitTest" ":packages:jetbrains-plugin:test"
75+
76+
- name: Patch Plugin XML
77+
run: |
78+
./gradlew ":packages:jetbrains-plugin:patchPluginXml"
79+
80+
- name: Verify Plugin
81+
run: |
82+
./gradlew ":packages:jetbrains-plugin:verifyPlugin"
83+
84+
- name: Patch Changelog
85+
run: |
86+
./gradlew ":packages:jetbrains-plugin:patchChangelog"
87+
88+
- name: Sign and Publish Plugin in Beta
89+
env:
90+
JB_PUBLISH_CHANNEL: "beta"
91+
run: |
92+
./gradlew ":packages:jetbrains-plugin:publishPlugin"
93+
94+
- name: Create Draft Release
95+
shell: bash
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.SVC_DEVTOOLSBOT_TOKEN }}
98+
run: |
99+
set -e
100+
echo Creating draft release for: "${RELEASE_TAG}"
101+
102+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
103+
git config --local user.name "github-actions[bot]"
104+
105+
git add .
106+
git commit --no-verify -m "Release ${RELEASE_TAG}"
107+
git tag ${RELEASE_TAG}
108+
git push origin ${RELEASE_TAG}
109+
110+
GIT_REF=$(git rev-parse ${RELEASE_TAG})
111+
ls packages/jetbrains-plugin/build/distributions/jetbrains-plugin.zip
112+
113+
CHANGELOG=$(./gradlew --quiet --console=plain :packages:jetbrains-plugin:getChangelog)
114+
115+
gh release create "${RELEASE_TAG}" \
116+
--title "${RELEASE_TAG}" \
117+
--notes "${CHANGELOG}" \
118+
--target "${GIT_REF}" \
119+
--draft \
120+
packages/jetbrains-plugin/build/distributions/jetbrains-plugin.zip
121+

Diff for: .github/workflows/publish-release.yaml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
prepare-release:
9+
name: "Prepare Release"
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
ref: ${{ github.ref_name }}
16+
fetch-depth: 0
17+
- name: Setup JDK
18+
uses: actions/setup-java@v4
19+
with:
20+
distribution: 'adopt'
21+
java-version: '17'
22+
cache: 'gradle'
23+
24+
- uses: robinraju/[email protected]
25+
with:
26+
tag: ${{ github.ref_name }}
27+
fileName: 'jetbrains-plugin.zip'
28+
out-file-path: 'packages/jetbrains-plugin/build/distributions/'
29+
- name: Publish Plugin In General Availability
30+
shell: bash
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.SVC_DEVTOOLSBOT_TOKEN }}
33+
JB_PUBLISH_CHANNEL: "ga"
34+
run: |
35+
set -e
36+
37+
./gradlew ":packages:jetbrains-plugin:publishPlugin" $(./gradlew ":packages:jetbrains-plugin:publishPlugin" --dry-run | awk '/^:/ { print "-x" $1 }' | sed '$ d')
38+
39+
git checkout main
40+
git merge ${{ github.ref_name }}
41+
git push origin main
42+

0 commit comments

Comments
 (0)