Skip to content

Commit 48ed2a8

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

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/workflows/release.yml

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

0 commit comments

Comments
 (0)