Skip to content

Commit a4654cc

Browse files
committed
Migrate Jenkins build to GH Actions
- readJSON can be replaced by 'jq' - "variables" can be persisted easily by appending to '$GITHUB_ENV' - maps can be simulated easily with 'declare -A ..' - actions/download-artifact can retrive artifacts uploaded under a re-usable workflow, if called as part of the same "root" workflow - Use github.event_name to ensure 'scheduled' events can publish pre-releases - Use job inputs/outputs to pass XML server version - Use 'environment' to simulate waiting for approval Signed-off-by: Roland Grunberg <[email protected]>
1 parent f99df7e commit a4654cc

File tree

2 files changed

+205
-4
lines changed

2 files changed

+205
-4
lines changed

.github/workflows/native-image.yaml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
name: native-image
22
on:
3-
schedule:
4-
- cron: '0 8 * * *'
3+
workflow_call:
4+
inputs:
5+
publishPreRelease:
6+
description: 'Publish a pre-release ?'
7+
required: true
8+
type: string
9+
default: 'true'
510
jobs:
11+
setup-xml-version:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
xml-server-version: ${{ steps.setup-xml-version.outputs.XML_SERVER_VERSION }}
15+
steps:
16+
- name: Check Out VS Code XML
17+
uses: actions/checkout@v2
18+
- id: setup-xml-version
19+
run: echo "XML_SERVER_VERSION=$(cat package.json | jq -r .xmlServer.version)" >> $GITHUB_OUTPUT
620
build-binary-unix:
721
runs-on: ${{ matrix.os }}
22+
needs: setup-xml-version
823
env:
924
GRAALVM_VERSION: 22.0.0.2
1025
GRAALVM_JAVA: java17
@@ -21,6 +36,7 @@
2136
- uses: actions/checkout@v2
2237
with:
2338
repository: 'eclipse/lemminx'
39+
ref: ${{ inputs.publishPreRelease == 'true' && 'main' || needs.setup-xml-version.outputs.xml-server-version }}
2440
- name: Cache Maven dependencies
2541
uses: actions/cache@v2
2642
with:
@@ -47,13 +63,14 @@
4763
- run: ./mvnw -B package -Dnative -DskipTests $([ $(uname -s) = Linux ] && echo "-Dgraalvm.static=-H:+StaticExecutableWithDynamicLibC") -Dcbi.jarsigner.skip=true
4864
- run: rm org.eclipse.lemminx/target/*.build_artifacts.txt
4965
- run: mv org.eclipse.lemminx/target/lemminx-* lemminx-${{ matrix.label }}
50-
- uses: actions/upload-artifact@v2
66+
- uses: actions/upload-artifact@v3
5167
with:
5268
name: lemminx-${{ matrix.label }}
5369
path: lemminx-${{ matrix.label }}
5470
if-no-files-found: error
5571
build-binary-windows:
5672
runs-on: windows-latest
73+
needs: setup-xml-version
5774
env:
5875
GRAALVM_VERSION: 22.0.0.2
5976
GRAALVM_JAVA: java17
@@ -62,6 +79,7 @@
6279
uses: actions/checkout@v2
6380
with:
6481
repository: 'eclipse/lemminx'
82+
ref: ${{ inputs.publishPreRelease == 'true' && 'main' || needs.setup-xml-version.outputs.xml-server-version }}
6583
- name: Cache Maven dependencies
6684
uses: actions/cache@v2
6785
with:
@@ -87,7 +105,7 @@
87105
java: ${{env.GRAALVM_JAVA}}
88106
- run: .\mvnw.cmd -B package -Dnative -DskipTests -D "cbi.jarsigner.skip=true"
89107
- run: mv org.eclipse.lemminx\target\lemminx-*.exe lemminx-win32.exe
90-
- uses: actions/upload-artifact@v2
108+
- uses: actions/upload-artifact@v3
91109
with:
92110
name: lemminx-win32
93111
path: lemminx-win32.exe

.github/workflows/release.yml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
name: release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
publishPreRelease:
7+
description: 'Publish a pre-release ?'
8+
required: true
9+
type: choice
10+
options:
11+
- 'true'
12+
- 'false'
13+
default: 'true'
14+
publishToMarketPlace:
15+
description: 'Publish to VS Code Marketplace ?'
16+
required: true
17+
type: choice
18+
options:
19+
- 'true'
20+
- 'false'
21+
default: 'false'
22+
publishToOVSX:
23+
description: 'Publish to OpenVSX Registry ?'
24+
required: true
25+
type: choice
26+
options:
27+
- 'true'
28+
- 'false'
29+
default: 'false'
30+
jobs:
31+
build-binaries-job:
32+
uses: rgrunber/vscode-xml/.github/workflows/native-image.yaml@main
33+
with:
34+
publishPreRelease: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true' }}
35+
packaging-job:
36+
runs-on: ubuntu-latest
37+
needs: build-binaries-job
38+
steps:
39+
- name: Checkout LemMinX
40+
if: "${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true' }}"
41+
uses: actions/checkout@v2
42+
with:
43+
repository: eclipse/lemminx
44+
- name: Build LemMinX Server Uber Jar
45+
if: "${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true' }}"
46+
run: |
47+
./mvnw clean verify -B -U -DskipTests
48+
mkdir ../staging
49+
cp org.eclipse.lemminx/target/org.eclipse.lemminx*-uber.jar ../staging
50+
- name: Check Out VS Code XML
51+
uses: actions/checkout@v2
52+
- name: Set Up NodeJS
53+
uses: actions/setup-node@v2
54+
with:
55+
node-version: '14'
56+
- name: Install dependencies
57+
run: npm install -g typescript "vsce" "ovsx"
58+
- run: echo "XML_SERVER_VERSION=$(cat package.json | jq -r .xmlServer.version)" >> $GITHUB_ENV
59+
- name: Download LemMinX Server Uber Jar
60+
env:
61+
downloadLocation: https://github.com/redhat-developer/vscode-xml
62+
if: "${{ inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true' }}"
63+
run: |
64+
curl -Lo org.eclipse.lemminx-${{ env.XML_SERVER_VERSION }}-uber.jar https://repo.eclipse.org/content/repositories/lemminx-releases/org/eclipse/lemminx/org.eclipse.lemminx/${{ env.XML_SERVER_VERSION }}/org.eclipse.lemminx-${{ env.XML_SERVER_VERSION }}-uber.jar
65+
sed -i -e "s|${{ env.downloadLocation }}/releases/download/latest|${{ env.downloadLocation }}/releases/download/${{ env.XML_SERVER_VERSION }}|g" package.json
66+
- name: Build vscode-xml
67+
run: |
68+
npm install
69+
npm run vscode:prepublish
70+
- run: |
71+
mkdir server/
72+
if [ -e org.eclipse.lemminx*-uber.jar ]; then
73+
cp org.eclipse.lemminx*-uber.jar server/
74+
else
75+
cp ../staging/org.eclipse.lemminx*-uber.jar server/
76+
fi
77+
- name: Prepare Pre-Release
78+
if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true' }}
79+
run: |
80+
npx gulp prepare_pre_release
81+
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
82+
echo "publishPreReleaseFlag=--pre-release" >> $GITHUB_ENV
83+
- name: Download LemMinX Binary Artifacts
84+
uses: actions/download-artifact@v3
85+
- name: Prepare Binary Artifacts For Packaging
86+
run: |
87+
mkdir -p ../staging/zips ../staging/checksums
88+
for f in lemminx-linux lemminx-osx-x86_64 lemminx-win32; do
89+
pushd ${f}
90+
chmod u+x ${f}*
91+
zip ../../staging/zips/${f}.zip ${f}*
92+
sha256sum ${f}* > ../../staging/checksums/${f}.sha256
93+
mv ${f}* ../../staging
94+
popd
95+
done
96+
ls -lashR ../staging
97+
- name: Package vscode-xml
98+
run: |
99+
declare -A targets
100+
targets["linux-x64"]=linux
101+
targets["win32-x64"]=win32
102+
targets["darwin-x64"]=osx-x86_64
103+
targets["darwin-arm64"]=osx-x86_64
104+
for tg in ${!targets[@]}; do
105+
cp ../staging/lemminx-${targets[${tg}]}* ./server
106+
cp ../staging/checksums/lemminx-${targets[${tg}]}.sha256 ./server
107+
vsce package ${{ env.publishPreReleaseFlag }} --target ${tg} -o vscode-xml-${tg}-${{ env.XML_SERVER_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
108+
rm ./server/lemminx-*
109+
done
110+
cp ../staging/checksums/lemminx-*.sha256 ./server
111+
vsce package -o vscode-xml-${{ env.XML_SERVER_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
112+
ls -lash *.vsix
113+
- name: Upload VSIX Artifacts
114+
uses: actions/upload-artifact@v2
115+
with:
116+
name: vscode-xml
117+
path: vscode-xml-*-${{ env.XML_SERVER_VERSION }}-${{github.run_number}}.vsix
118+
if-no-files-found: error
119+
- name: Upload LemMinX Uber Jar
120+
uses: actions/upload-artifact@v2
121+
with:
122+
name: lemminx-uber-jar
123+
path: server/org.eclipse.lemminx*-uber.jar
124+
if-no-files-found: error
125+
- name: Publish to GH Release Tab
126+
if: ${{ inputs.publishToMarketPlace == 'true' && inputs.publishToOVSX == 'true' }}
127+
uses: "marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0"
128+
with:
129+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
130+
automatic_release_tag: "${{ env.XML_SERVER_VERSION }}"
131+
draft: true
132+
files: |
133+
vscode-xml-*-${{ env.XML_SERVER_VERSION }}-${{ github.run_number }}.vsix
134+
../staging/zips/lemminx-*
135+
../staging/checksums/lemminx-*
136+
release-job:
137+
environment: ${{ (inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true') && 'release' || 'pre-release' }}
138+
runs-on: ubuntu-latest
139+
needs: packaging-job
140+
steps:
141+
- name: Check Out VS Code XML
142+
uses: actions/checkout@v2
143+
- name: Set Up NodeJS
144+
uses: actions/setup-node@v2
145+
with:
146+
node-version: '14'
147+
- name: Install dependencies
148+
run: npm install -g typescript "vsce" "ovsx"
149+
- run: echo "XML_SERVER_VERSION=$(cat package.json | jq -r .xmlServer.version)" >> $GITHUB_ENV
150+
- name: Set the link to download the binary server
151+
env:
152+
downloadLocation: https://github.com/redhat-developer/vscode-xml
153+
if: ${{ inputs.publishToMarketPlace == 'true' }}
154+
run: sed -i -e "s|${{ env.downloadLocation }}/releases/download/latest|${{ env.downloadLocation }}/releases/download/${{ env.XML_SERVER_VERSION }}|g" package.json
155+
- name: Download VSIX & LemMinX Server Uber Jar
156+
uses: actions/download-artifact@v3
157+
- name: Build vscode-xml
158+
run: |
159+
npm install
160+
npm run vscode:prepublish
161+
- run: |
162+
mkdir server/
163+
mv lemminx-uber-jar/org.eclipse.lemminx*-uber.jar server/
164+
- name: Prepare Pre-Release
165+
if: ${{ github.event_name == 'schedule' || inputs.publishPreRelease == 'true' }}
166+
run: |
167+
npx gulp prepare_pre_release
168+
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
169+
echo "publishPreReleaseFlag=--pre-release" >> $GITHUB_ENV
170+
- name: Publish to VS Code Marketplace
171+
if: ${{ github.event_name == 'schedule' || inputs.publishToMarketPlace == 'true' || inputs.publishPreRelease == 'true' }}
172+
run: |
173+
for platformVsix in vscode-xml/vscode-xml-*-${{ env.XML_SERVER_VERSION }}-${GITHUB_RUN_NUMBER}.vsix; do
174+
vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath ${platformVsix}
175+
done
176+
vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} ${{ env.publishPreReleaseFlag }}
177+
- name: Publish to OpenVSX Registry
178+
if: ${{ github.event_name == 'schedule' || inputs.publishToOVSX == 'true' || inputs.publishPreRelease == 'true' }}
179+
run: |
180+
for platformVsix in vscode-xml/vscode-xml-*-${{ env.XML_SERVER_VERSION }}-${GITHUB_RUN_NUMBER}.vsix; do
181+
ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath ${platformVsix}
182+
done
183+
ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} ${{ env.publishPreReleaseFlag }}

0 commit comments

Comments
 (0)