Skip to content

Commit 5e4d93a

Browse files
committed
Migrate Jenkins release job to GitHub Actions.
- Preserve existing Jenkinsfile as a fallback Signed-off-by: Roland Grunberg <[email protected]>
1 parent d244b64 commit 5e4d93a

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed

.github/workflows/release.yml

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
name: release
2+
3+
on:
4+
schedule:
5+
- cron: '0 8 * * *'
6+
workflow_dispatch:
7+
inputs:
8+
JDT_LS_VERSION:
9+
description: 'The (optional) release version (including qualifier) of JDT-LS to use.'
10+
type: string
11+
publishPreRelease:
12+
description: 'Publish a pre-release ?'
13+
required: true
14+
type: choice
15+
options:
16+
- 'true'
17+
- 'false'
18+
default: 'true'
19+
publishToMarketPlace:
20+
description: 'Publish to VS Code Marketplace ?'
21+
required: true
22+
type: choice
23+
options:
24+
- 'true'
25+
- 'false'
26+
default: 'false'
27+
publishToOVSX:
28+
description: 'Publish to OpenVSX Registry ?'
29+
required: true
30+
type: choice
31+
options:
32+
- 'true'
33+
- 'false'
34+
default: 'false'
35+
jobs:
36+
should-build-change:
37+
runs-on: ubuntu-latest
38+
outputs:
39+
repo-cache-hit: ${{ steps.cache-last-commit.outputs.cache-hit }}
40+
steps:
41+
- uses: actions/checkout@v3
42+
with:
43+
repository: 'eclipse-jdtls/eclipse.jdt.ls'
44+
fetch-depth: 2
45+
path: eclipse.jdt.ls
46+
- uses: actions/checkout@v3
47+
with:
48+
repository: 'redhat-developer/vscode-java'
49+
fetch-depth: 2
50+
path: vscode-java
51+
- run: |
52+
pushd eclipse.jdt.ls
53+
git rev-parse HEAD >> ../lastCommit
54+
popd
55+
pushd vscode-java
56+
git rev-parse HEAD >> ../lastCommit
57+
- name: Check New Changes
58+
id: cache-last-commit
59+
uses: actions/cache@v2
60+
with:
61+
path: lastCommit
62+
key: lastCommit-${{ hashFiles('lastCommit') }}
63+
packaging-job:
64+
runs-on: ubuntu-latest
65+
needs: should-build-change
66+
if: ${{ needs.should-build-change.outputs.repo-cache-hit != 'true' || github.event_name != 'schedule' }}
67+
steps:
68+
- name: Checkout JDT-LS
69+
if: "${{ inputs.JDT_LS_VERSION == '' }}"
70+
uses: actions/checkout@v2
71+
with:
72+
repository: eclipse-jdtls/eclipse.jdt.ls
73+
- name: Cache Maven local repository
74+
uses: actions/cache@v2
75+
with:
76+
path: |
77+
~/.m2/repository
78+
~/.m2/wrapper
79+
!~/.m2/repository/org/eclipse/jdt/ls
80+
key: maven-local-${{ hashFiles('**/pom.xml') }}
81+
- name: Set Up Java
82+
uses: actions/setup-java@v2
83+
with:
84+
java-version: '17'
85+
distribution: 'adopt'
86+
- name: Build JDT-LS
87+
if: "${{ inputs.JDT_LS_VERSION == '' }}"
88+
run: |
89+
./mvnw clean verify -B -DskipTests -Pserver-distro
90+
mkdir ../staging
91+
cp org.eclipse.jdt.ls.product/distro/jdt-language-server-*.tar.gz ../staging
92+
- name: Check Out VS Code Java
93+
uses: actions/checkout@v2
94+
- name: Set Up NodeJS
95+
uses: actions/setup-node@v2
96+
with:
97+
node-version: '18'
98+
- name: Install NodeJS dependencies
99+
run: npm install -g typescript "@vscode/vsce" "ovsx"
100+
- name: Download JDT-LS Release
101+
if: "${{ inputs.JDT_LS_VERSION != '' }}"
102+
run: |
103+
version=`echo ${{ inputs.JDT_LS_VERSION }} | cut -d- -f1`
104+
curl -LO https://download.eclipse.org/jdtls/milestones/${version}/jdt-language-server-${{ inputs.JDT_LS_VERSION }}.tar.gz
105+
- name: Build vscode-java
106+
run: |
107+
npm install
108+
npm run vscode:prepublish
109+
npm run compile
110+
- name: Test vscode-java
111+
env:
112+
SKIP_COMMANDS_TEST: true
113+
SKIP_CLASSPATH_TEST: true
114+
run: |
115+
$(echo "xvfb-run --auto-servernum") npm run test --silent
116+
continue-on-error: true
117+
- name: Clean tests
118+
run: npx gulp clean_test_folder
119+
- name: Prepare Lombok Support
120+
run: |
121+
npx gulp download_lombok
122+
- name: Prepare Pre-Release
123+
if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true' }}
124+
run: |
125+
npx gulp prepare_pre_release
126+
echo "publishPreReleaseFlag=--pre-release" >> $GITHUB_ENV
127+
- name: Prepare JDT-LS
128+
run: |
129+
rm -rf ./out
130+
mkdir server/
131+
if [ -e jdt-language-server-*.tar.gz ]; then
132+
tar -xf jdt-language-server-*.tar.gz -C server/
133+
else
134+
tar -xf ../staging/jdt-language-server-*.tar.gz -C server/
135+
fi
136+
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
137+
- name: Package vscode-java
138+
run: |
139+
platforms=("win32-x64" "linux-x64" "linux-arm64" "darwin-x64" "darwin-arm64")
140+
for platform in ${platforms[@]}; do
141+
npx gulp download_jre --target ${platform} --javaVersion 17
142+
vsce package ${{ env.publishPreReleaseFlag }} --target ${platform} -o java-${platform}-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
143+
done
144+
rm -rf jre/
145+
vsce package ${{ env.publishPreReleaseFlag }} -o vscode-java-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
146+
ls -lash *.vsix
147+
- name: Upload VSIX Artifacts
148+
uses: actions/upload-artifact@v2
149+
with:
150+
name: vscode-java
151+
path: |
152+
java-*-${{ env.EXT_VERSION }}-${{github.run_number}}.vsix
153+
vscode-java-${{ env.EXT_VERSION }}-${{github.run_number}}.vsix
154+
if-no-files-found: error
155+
- name: Publish to GH Release Tab
156+
if: ${{ inputs.publishToMarketPlace == 'true' && inputs.publishToOVSX == 'true' }}
157+
uses: "marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0"
158+
with:
159+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
160+
automatic_release_tag: "v${{ env.EXT_VERSION }}"
161+
title: "${{ env.EXT_VERSION }}"
162+
draft: true
163+
files: |
164+
java-*-${{ env.EXT_VERSION }}-${{github.run_number}}.vsix
165+
vscode-java-${{ env.EXT_VERSION }}-${{ github.run_number }}.vsix
166+
release-job:
167+
environment: ${{ (inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true') && 'release' || 'pre-release' }}
168+
runs-on: ubuntu-latest
169+
needs: packaging-job
170+
steps:
171+
- name: Set Up NodeJS
172+
uses: actions/setup-node@v2
173+
with:
174+
node-version: '18'
175+
- name: Install dependencies
176+
run: |
177+
npm install -g typescript "@vscode/vsce" "ovsx"
178+
- name: Download VSIX & JDT-LS
179+
uses: actions/download-artifact@v3
180+
- name: Publish to VS Code Marketplace
181+
if: ${{ github.event_name == 'schedule' || inputs.publishToMarketPlace == 'true' || inputs.publishPreRelease == 'true' }}
182+
run: |
183+
for platformVsix in vscode-java/java-*-*-${GITHUB_RUN_NUMBER}.vsix; do
184+
vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath ${platformVsix}
185+
done
186+
vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath vscode-java/vscode-java-*-${GITHUB_RUN_NUMBER}.vsix
187+
- name: Publish to OpenVSX Registry
188+
if: ${{ github.event_name == 'schedule' || inputs.publishToOVSX == 'true' || inputs.publishPreRelease == 'true' }}
189+
run: |
190+
for platformVsix in vscode-java/java-*-*-${GITHUB_RUN_NUMBER}.vsix; do
191+
ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath ${platformVsix}
192+
done
193+
ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath vscode-java/vscode-java-*-${GITHUB_RUN_NUMBER}.vsix

0 commit comments

Comments
 (0)