Skip to content

Commit d4a2765

Browse files
committed
build actions
1 parent 39cb83f commit d4a2765

File tree

5 files changed

+403
-1
lines changed

5 files changed

+403
-1
lines changed

.github/dependabot.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Dependabot configuration:
2+
# https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/configuration-options-for-dependency-updates
3+
4+
version: 2
5+
updates:
6+
# Maintain dependencies for root project Gradle dependencies
7+
- package-ecosystem: "gradle"
8+
directory: "/"
9+
target-branch: "next"
10+
schedule:
11+
interval: "daily"
12+
groups:
13+
gradle-dependencies:
14+
patterns:
15+
- "*"
16+
17+
# Maintain dependencies for intellij-aicoder module
18+
- package-ecosystem: "gradle"
19+
directory: "/intellij-aicoder"
20+
target-branch: "next"
21+
schedule:
22+
interval: "daily"
23+
groups:
24+
intellij-dependencies:
25+
patterns:
26+
- "*"
27+
28+
# Maintain dependencies for GitHub Actions
29+
- package-ecosystem: "github-actions"
30+
directory: "/.github/workflows"
31+
target-branch: "next"
32+
schedule:
33+
interval: "daily"
34+
groups:
35+
github-actions:
36+
patterns:
37+
- "*"

.github/workflows/build.yml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: Build
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
11+
defaults:
12+
run:
13+
working-directory: intellij-aicoder
14+
15+
jobs:
16+
build:
17+
name: Build
18+
runs-on: ubuntu-latest
19+
outputs:
20+
version: ${{ steps.properties.outputs.version }}
21+
changelog: ${{ steps.properties.outputs.changelog }}
22+
pluginVerifierHomeDir: ${{ steps.properties.outputs.pluginVerifierHomeDir }}
23+
steps:
24+
- name: Fetch Sources
25+
uses: actions/checkout@v4
26+
27+
- name: Gradle Wrapper Validation
28+
uses: gradle/actions/wrapper-validation@v3
29+
with:
30+
working-directory: intellij-aicoder
31+
32+
- name: Setup Java
33+
uses: actions/setup-java@v4
34+
with:
35+
distribution: zulu
36+
java-version: 17
37+
38+
- name: Setup Gradle
39+
uses: gradle/actions/setup-gradle@v4
40+
with:
41+
gradle-home-cache-cleanup: true
42+
43+
- name: Export Properties
44+
id: properties
45+
shell: bash
46+
run: |
47+
PROPERTIES="$(./gradlew properties --console=plain -q)"
48+
VERSION="$(echo "$PROPERTIES" | grep "^version:" | cut -f2- -d ' ')"
49+
CHANGELOG="$(./gradlew getChangelog --unreleased --no-header --console=plain -q)"
50+
51+
echo "version=$VERSION" >> $GITHUB_OUTPUT
52+
echo "pluginVerifierHomeDir=~/.pluginVerifier" >> $GITHUB_OUTPUT
53+
54+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
55+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
56+
echo "EOF" >> $GITHUB_OUTPUT
57+
58+
- name: Build plugin
59+
run: ./gradlew buildPlugin
60+
61+
- name: Prepare Plugin Artifact
62+
id: artifact
63+
shell: bash
64+
run: |
65+
cd ${{ github.workspace }}/intellij-aicoder/build/distributions
66+
FILENAME=`ls *.zip`
67+
echo "filename=${FILENAME:0:-4}" >> $GITHUB_OUTPUT
68+
69+
- name: Upload artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: ${{ steps.artifact.outputs.filename }}
73+
path: intellij-aicoder/build/distributions/*
74+
75+
test:
76+
name: Test
77+
needs: [ build ]
78+
runs-on: ubuntu-latest
79+
steps:
80+
- name: Fetch Sources
81+
uses: actions/checkout@v4
82+
83+
- name: Setup Java
84+
uses: actions/setup-java@v4
85+
with:
86+
distribution: zulu
87+
java-version: 17
88+
89+
- name: Setup Gradle
90+
uses: gradle/actions/setup-gradle@v4
91+
92+
- name: Run Tests
93+
run: ./gradlew check
94+
95+
- name: Collect Tests Result
96+
if: ${{ failure() }}
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: tests-result
100+
path: intellij-aicoder/build/reports/tests
101+
102+
- name: Upload Code Coverage Report
103+
uses: codecov/codecov-action@v4
104+
with:
105+
files: intellij-aicoder/build/reports/kover/report.xml
106+
107+
verify:
108+
name: Verify plugin
109+
needs: [ build ]
110+
runs-on: ubuntu-latest
111+
steps:
112+
- name: Maximize Build Space
113+
uses: jlumbroso/free-disk-space@main
114+
with:
115+
tool-cache: false
116+
large-packages: false
117+
118+
- name: Fetch Sources
119+
uses: actions/checkout@v4
120+
121+
- name: Setup Java
122+
uses: actions/setup-java@v4
123+
with:
124+
distribution: zulu
125+
java-version: 17
126+
127+
- name: Setup Gradle
128+
uses: gradle/actions/setup-gradle@v4
129+
130+
- name: Setup Plugin Verifier IDEs Cache
131+
uses: actions/cache@v4
132+
with:
133+
path: ${{ needs.build.outputs.pluginVerifierHomeDir }}/ides
134+
key: plugin-verifier-${{ hashFiles('intellij-aicoder/build/listProductsReleases.txt') }}
135+
136+
- name: Run Plugin Verification tasks
137+
run: ./gradlew verifyPlugin -Dplugin.verifier.home.dir=${{ needs.build.outputs.pluginVerifierHomeDir }}
138+
139+
- name: Collect Plugin Verifier Result
140+
if: ${{ always() }}
141+
uses: actions/upload-artifact@v4
142+
with:
143+
name: pluginVerifier-result
144+
path: intellij-aicoder/build/reports/pluginVerifier
145+
146+
releaseDraft:
147+
name: Release draft
148+
if: github.event_name != 'pull_request'
149+
needs: [ build, test, verify ]
150+
runs-on: ubuntu-latest
151+
permissions:
152+
contents: write
153+
steps:
154+
- name: Fetch Sources
155+
uses: actions/checkout@v4
156+
157+
- name: Remove Old Release Drafts
158+
env:
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
run: |
161+
gh api repos/{owner}/{repo}/releases \
162+
--jq '.[] | select(.draft == true) | .id' \
163+
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
164+
165+
- name: Create Release Draft
166+
id: create_release
167+
env:
168+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
169+
run: |
170+
gh release create "v${{ needs.build.outputs.version }}" \
171+
--draft \
172+
--title "v${{ needs.build.outputs.version }}" \
173+
--notes "${{ needs.build.outputs.changelog }}"
174+
RELEASE_URL=$(gh release view "v${{ needs.build.outputs.version }}" --json url -q .url)
175+
echo "release_url=$RELEASE_URL" >> $GITHUB_OUTPUT
176+
177+
- name: Download Artifact
178+
uses: actions/download-artifact@v4
179+
with:
180+
name: ${{ steps.artifact.outputs.filename }}
181+
path: ./artifact
182+
183+
- name: Upload Release Asset
184+
uses: actions/upload-release-asset@v1
185+
env:
186+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
187+
with:
188+
upload_url: ${{ steps.create_release.outputs.release_url }}
189+
asset_path: ./artifact/intellij-aicoder-${{ needs.build.outputs.version }}/intellij-aicoder-${{ needs.build.outputs.version }}.zip
190+
asset_name: intellij-aicoder-${{ needs.build.outputs.version }}.zip
191+
asset_content_type: application/zip

.github/workflows/release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [prereleased, released]
5+
6+
defaults:
7+
run:
8+
working-directory: intellij-aicoder
9+
10+
jobs:
11+
release:
12+
name: Publish Plugin
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
steps:
18+
- name: Free Disk Space
19+
uses: jlumbroso/free-disk-space@main
20+
with:
21+
tool-cache: false
22+
large-packages: false
23+
24+
- name: Fetch Sources
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.release.tag_name }}
28+
29+
- name: Setup Java
30+
uses: actions/setup-java@v4
31+
with:
32+
distribution: zulu
33+
java-version: 17
34+
35+
- name: Setup Gradle
36+
uses: gradle/actions/setup-gradle@v4
37+
38+
- name: Export Properties
39+
id: properties
40+
shell: bash
41+
run: |
42+
CHANGELOG="$(cat << 'EOM' | sed -e 's/^[[:space:]]*$//g' -e '/./,$!d'
43+
${{ github.event.release.body }}
44+
EOM
45+
)"
46+
47+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
48+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
49+
echo "EOF" >> $GITHUB_OUTPUT
50+
51+
- name: Publish Plugin
52+
env:
53+
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
54+
CERTIFICATE_CHAIN: ${{ secrets.CERTIFICATE_CHAIN }}
55+
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
56+
PRIVATE_KEY_PASSWORD: ${{ secrets.PRIVATE_KEY_PASSWORD }}
57+
run: ./gradlew publishPlugin -x test
58+
59+
- name: Upload Release Asset
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
cd ${{ github.workspace }}/intellij-aicoder/build/distributions
64+
for file in *; do
65+
gh release upload ${{ github.event.release.tag_name }} "$file"
66+
done
67+
68+
- name: Create Pull Request
69+
if: ${{ steps.properties.outputs.changelog != '' }}
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
run: |
73+
VERSION="${{ github.event.release.tag_name }}"
74+
BRANCH="changelog-update-$VERSION"
75+
LABEL="release changelog"
76+
77+
git config user.email "[email protected]"
78+
git config user.name "GitHub Action"
79+
80+
git checkout -b $BRANCH
81+
82+
# Ensure we're modifying the changelog in the correct module
83+
cd ${{ github.workspace }}/intellij-aicoder
84+
85+
git add CHANGELOG.md
86+
git commit -m "Changelog update - $VERSION"
87+
git push --set-upstream origin $BRANCH
88+
89+
gh label create "$LABEL" \
90+
--description "Pull requests with release changelog update" \
91+
--force \
92+
|| true
93+
94+
gh pr create \
95+
--title "Changelog update - \`$VERSION\`" \
96+
--body "Current pull request contains patched \`CHANGELOG.md\` file for the \`$VERSION\` version." \
97+
--label "$LABEL" \
98+
--head $BRANCH

0 commit comments

Comments
 (0)