Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GH actions for vscode-knative release #350

Merged
113 changes: 113 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: release

on:
workflow_dispatch:
inputs:
publishPreRelease:
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
description: "Publish a pre-release ?"
required: true
type: choice
options:
- "true"
- "false"
default: "true"
publishToMarketPlace:
description: "Publish to VS Code Marketplace ?"
required: true
type: choice
options:
- "true"
- "false"
default: "false"
publishToOVSX:
description: "Publish to OpenVSX Registry ?"
required: true
type: choice
options:
- "true"
- "false"
default: "false"
jobs:
packaging-job:
runs-on: ubuntu-latest
steps:
- name: Checkout vscode-knative
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
- name: Install dependencies
run: |
npm install -g typescript "vsce" "ovsx"
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
npm install
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
- name: Build And Run Unit Tests
uses: coactions/setup-xvfb@b6b4fcfb9f5a895edadc3bc76318fae0ac17c8b3 #v1.0.1
with:
run: npm run test
- name: Package
run: |
jq --tab '.extensionDependencies += [ "ms-kubernetes-tools.vscode-kubernetes-tools" ]' package.json > package.json.new
mv package.json.new package.json
node ./out/build/update-readme.js
declare -A targets
targets["win32-x64"]=win32
targets["win32-arm64"]=win32
targets["linux-x64"]=linux
targets["linux-arm64"]=linux-arm64
targets["darwin-x64"]=darwin
targets["darwin-arm64"]=darwin
for target in ${!targets[@]}; do
export TARGET=${targets[${target}]}
vsce package --target ${target} -o vscode-knative-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}-${target}.vsix
sha256sum *-${target}.vsix > vscode-knative-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}-${target}.vsix.sha256
done
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
ls -lash *.vsix *.sha256
- name: Upload VSIX Artifacts
uses: actions/upload-artifact@v4
with:
name: vscode-knative
path: vscode-knative*-${{ env.EXT_VERSION }}-${{github.run_number}}*.vsix
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
if-no-files-found: error
- name: Publish to GH Release Tab
if: ${{ inputs.publishToMarketPlace == 'true' && inputs.publishToOVSX == 'true' }}
uses: "marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.EXT_VERSION }}"
draft: true
files: |
vscode-knative-${{ env.EXT_VERSION }}-${{github.run_number}}*.vsix
vscode-knative-${{ env.EXT_VERSION }}-${{github.run_number}}*.sha256
rgrunber marked this conversation as resolved.
Show resolved Hide resolved

release-job:
if: ${{ inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true' }}
environment: ${{ (inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true') && 'release' || 'pre-release' }}
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
needs: packaging-job
steps:
- name: Checkout vscode-knative
uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: |
npm install -g typescript "vsce" "ovsx"
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
- name: Download VSIX Artifacts
uses: actions/download-artifact@v4
- name: Publish to VS Code Marketplace
if: ${{ github.event_name == 'schedule' || inputs.publishToMarketPlace == 'true' || inputs.publishPreRelease == 'true' }}
run: |
for platform in darwin-x64 darwin-arm64 linux-x64 win32-x64 win32-arm64; do
vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath vscode-knative/vscode-knative-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}-${platform}.vsix
done
- name: Publish to OpenVSX Registry
if: ${{ github.event_name == 'schedule' || inputs.publishToOVSX == 'true' || inputs.publishPreRelease == 'true' }}
run: |
for platform in darwin-x64 darwin-arm64 linux-x64 win32-x64 win32-arm64; do
ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath vscode-knative/vscode-knative-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}-${platform}.vsix
done
15 changes: 15 additions & 0 deletions build/update-readme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*-----------------------------------------------------------------------------------------------
* Copyright (c) Red Hat, Inc. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*-----------------------------------------------------------------------------------------------*/

import { readFileSync, writeFileSync } from 'fs-extra';

const readme = readFileSync('./README.md');

// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
const lines = `${readme}`.split('\n');

const index = lines.findIndex((line) => line.includes('## Overview'));
lines.splice(0, index + 1);
writeFileSync('./README.md', lines.join('\n'));
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
],
"icon": "images/knative-logo.png",
"engines": {
"vscode": "^1.52.0"
"vscode": "^1.64.2"
},
"categories": [
"Programming Languages",
Expand Down Expand Up @@ -99,7 +99,7 @@
"@types/string-format": "^2.0.0",
"@types/tmp": "0.2.0",
"@types/validator": "^13.1.3",
"@types/vscode": "^1.52.0",
"@types/vscode": "1.64.0",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.0.2",
"chai": "^4.3.0",
Expand Down
Loading