Skip to content

Commit 0c068aa

Browse files
committed
Migrate Jenkins release build to GitHub Actions.
Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
1 parent 7dccf83 commit 0c068aa

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

.github/workflows/release.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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+
31+
jobs:
32+
packaging-job:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout vscode-openshift-tools
36+
uses: actions/checkout@v3
37+
- name: Use Node.js
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: 16
41+
- name: Install dependencies
42+
run: |
43+
npm install -g typescript "vsce" "ovsx"
44+
npm install
45+
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
46+
- name: Build And Run Unit Tests
47+
uses: coactions/setup-xvfb@b6b4fcfb9f5a895edadc3bc76318fae0ac17c8b3 #v1.0.1
48+
with:
49+
run: npm run test
50+
- name: Package
51+
run: |
52+
jq --tab '.extensionDependencies += [ "ms-kubernetes-tools.vscode-kubernetes-tools" ]' package.json > package.json.new
53+
mv package.json.new package.json
54+
node ./out/build/update-readme.js
55+
56+
declare -A targets
57+
targets["win32-x64"]=win32
58+
targets["win32-arm64"]=win32
59+
targets["linux-x64"]=linux
60+
targets["darwin-x64"]=darwin
61+
targets["darwin-arm64"]=darwin
62+
63+
for target in ${!targets[@]}; do
64+
export TARGET=${targets[${target}]}
65+
vsce package --target ${target} -o openshift-toolkit-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}-${target}.vsix
66+
sha256sum *-${target}.vsix > openshift-toolkit-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}-${target}.vsix.sha256
67+
done
68+
69+
ls -lash *.vsix *.sha256
70+
- name: Upload VSIX Artifacts
71+
uses: actions/upload-artifact@v2
72+
with:
73+
name: openshift-toolkit
74+
path: openshift-toolkit*-${{ env.EXT_VERSION }}-${{github.run_number}}*.vsix
75+
if-no-files-found: error
76+
- name: Publish to GH Release Tab
77+
if: ${{ inputs.publishToMarketPlace == 'true' && inputs.publishToOVSX == 'true' }}
78+
uses: "marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0"
79+
with:
80+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
81+
automatic_release_tag: "${{ env.EXT_VERSION }}"
82+
draft: true
83+
files: |
84+
openshift-toolkit-${{ env.EXT_VERSION }}-${{github.run_number}}*.vsix
85+
openshift-toolkit-${{ env.EXT_VERSION }}-${{github.run_number}}*.sha256
86+
87+
release-job:
88+
if: ${{ inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true' }}
89+
environment: ${{ (inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true') && 'release' || 'pre-release' }}
90+
runs-on: ubuntu-latest
91+
needs: packaging-job
92+
steps:
93+
- name: Checkout vscode-openshift-tools
94+
uses: actions/checkout@v3
95+
- name: Use Node.js
96+
uses: actions/setup-node@v3
97+
with:
98+
node-version: 16
99+
- name: Install dependencies
100+
run: |
101+
npm install -g typescript "vsce" "ovsx"
102+
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
103+
- name: Download VSIX Artifacts
104+
uses: actions/download-artifact@v3
105+
- name: Publish to VS Code Marketplace
106+
if: ${{ github.event_name == 'schedule' || inputs.publishToMarketPlace == 'true' || inputs.publishPreRelease == 'true' }}
107+
run: |
108+
for platform in darwin-x64 darwin-arm64 linux-x64 win32-x64 win32-arm64; do
109+
vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath openshift-toolkit/openshift-toolkit-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}-${platform}.vsix
110+
done
111+
- name: Publish to OpenVSX Registry
112+
if: ${{ github.event_name == 'schedule' || inputs.publishToOVSX == 'true' || inputs.publishPreRelease == 'true' }}
113+
run: |
114+
for platform in darwin-x64 darwin-arm64 linux-x64 win32-x64 win32-arm64; do
115+
ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath openshift-toolkit/openshift-toolkit-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}-${platform}.vsix
116+
done

0 commit comments

Comments
 (0)