Skip to content

Release extension version 1.4.3 (#151) #131

Release extension version 1.4.3 (#151)

Release extension version 1.4.3 (#151) #131

Workflow file for this run

name: Release and Publish extension
on:
push:
branches:
- main
paths:
- package.json
workflow_dispatch:
inputs:
version:
description: "Version to release"
required: true
jobs:
check-version-change:
env:
EXT_VERSION: ${{ github.event.inputs.version }}
outputs:
changed: ${{ steps.check-version.outputs.result }}
version: ${{ env.EXT_VERSION }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- name: Check if version has changed
id: check-version
uses: actions/github-script@v6
with:
script: |
const version = '${{ github.event.inputs.version }}' || require('./package.json').version;
// Find a release for that version
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: `${version}`,
}).catch(() => null);
// If the release exists, the version has not changed
if (release) {
console.log(`Version ${version} has an existing release`);
console.log(release.data.html_url);
core.summary.addLink(`Release v${version}`, release.data.html_url);
await core.summary.write();
return "false";
}
console.log(`Version ${version} does not have a release`);
return true;
- name: Export Version
run: |
echo "EXT_VERSION=$(node -p -e "require('./package.json').version")" >> $GITHUB_ENV
release:
name: Release extension v${{ needs.check-version-change.outputs.version }} for ${{ matrix.vsce_target }}
needs:
- check-version-change
if: ${{ needs.check-version-change.outputs.changed == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
strategy:
matrix:
include:
- vsce_target: web
ls_target: web_noop
npm_config_arch: x64
- vsce_target: linux-x64
ls_target: linux_amd64
npm_config_arch: x64
- vsce_target: linux-arm64
ls_target: linux_arm64
npm_config_arch: arm64
- vsce_target: linux-armhf
ls_target: linux_arm
npm_config_arch: arm
- vsce_target: darwin-x64
ls_target: darwin_amd64
npm_config_arch: x64
- vsce_target: darwin-arm64
ls_target: darwin_arm64
npm_config_arch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- run: npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm_config_arch: ${{ matrix.npm_config_arch }}
ls_target: ${{ matrix.ls_target }}
- name: Create a package.json that actions/upload will like
run: |
cp package.json package.json.real
sed --regexp-extended '/"name"\s*:/ s#@[a-zA-Z\\-]+/##' package.json.real > package.json
- name: Insert Variables
run: |
./.github/workflow_scripts/insert-secrets.sh
env:
AMPLITUDE_API_KEY: ${{ secrets.AMPLITUDE_API_KEY }}
PARALLELS_CATALOG_URL: ${{ secrets.PARALLELS_CATALOG_URL }}
PARALLELS_CATALOG_BUSINESS_PASSWORD: ${{ secrets.PARALLELS_CATALOG_BUSINESS_PASSWORD }}
PARALLELS_CATALOG_BUSINESS_USER: ${{ secrets.PARALLELS_CATALOG_BUSINESS_USER }}
PARALLELS_CATALOG_PRO_PASSWORD: ${{ secrets.PARALLELS_CATALOG_PRO_PASSWORD }}
PARALLELS_CATALOG_PRO_USER: ${{ secrets.PARALLELS_CATALOG_PRO_USER }}
- run: npm ci
env:
npm_config_arch: ${{ matrix.npm_config_arch }}
ls_target: ${{ matrix.ls_target }}
- name: Package Stable VSIX
run: npm run package -- --target=${{ matrix.vsce_target }}
- name: Upload vsix as artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: ${{ matrix.vsce_target }}
path: "*.vsix"
- name: Restore old package.json
run: mv package.json.real package.json
release-win:
name: Release extension v${{ needs.check-version-change.outputs.version }} for ${{ matrix.vsce_target }}
needs:
- check-version-change
if: ${{ needs.check-version-change.outputs.changed == 'true' }}
runs-on: windows-latest
permissions:
contents: write
packages: read
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
strategy:
matrix:
include:
- vsce_target: win32-x64
ls_target: windows_amd64
npm_config_arch: x64
- vsce_target: win32-arm64
ls_target: windows_arm64
npm_config_arch: arm64
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
registry-url: "https://npm.pkg.github.com"
- name: create a package.json that actions/upload will like
run: |
cp package.json package.json.real
sed --regexp-extended '/"name"\s*:/ s#@[a-zA-Z\\-]+/##' package.json.real > package.json
- name: Install dependencies
run: |
npm ci
env:
npm_config_arch: ${{ matrix.npm_config_arch }}
ls_target: ${{ matrix.ls_target }}
- name: Package stable VSIX
run: npm run package -- --target=${{ matrix.vsce_target }}
- name: Upload vsix as artifact
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
name: ${{ matrix.vsce_target }}
path: "*.vsix"
- name: Restore old package.json
run: |
del package.json
move package.json.real package.json
create-release:
name: Create release v${{ needs.check-version-change.outputs.version }}
needs:
- release
- release-win
- check-version-change
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
- name: Generate release notes
run: |
./.github/workflow_scripts/get-latest-changelog.sh --output-to-file
cat release_notes.md
- name: Create release and upload release asset
uses: actions/github-script@v6
with:
script: |
const fs = require("fs");
const release = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
body: fs.readFileSync("release_notes.md", "utf8"),
tag_name: "v${{ env.EXT_VERSION }}",
name: "v${{ env.EXT_VERSION }}",
draft: false,
prerelease: false
});
upload-artifacts-to-release:
name: Upload artifacts to release v${{ needs.check-version-change.outputs.version }}
needs:
- create-release
- check-version-change
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
strategy:
matrix:
include:
- vsce_target: web
ls_target: web_noop
npm_config_arch: x64
- vsce_target: win32-x64
ls_target: windows_amd64
npm_config_arch: x64
- vsce_target: win32-arm64
ls_target: windows_arm64
npm_config_arch: arm
- vsce_target: linux-x64
ls_target: linux_amd64
npm_config_arch: x64
- vsce_target: linux-arm64
ls_target: linux_arm64
npm_config_arch: arm64
- vsce_target: linux-armhf
ls_target: linux_arm
npm_config_arch: arm
- vsce_target: darwin-x64
ls_target: darwin_amd64
npm_config_arch: x64
- vsce_target: darwin-arm64
ls_target: darwin_arm64
npm_config_arch: arm64
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: ${{ matrix.vsce_target }}
- name: Upload artifact to release
env:
GH_TOKEN: ${{ secrets.GHUB_PAT }}
run: |
ls -la
gh release upload v${{ env.EXT_VERSION }} *.vsix
- name: Create release and upload release asset
if: false
uses: actions/github-script@v6
with:
script: |
const fs = require("fs");
const path = "./parallels-desktop-${{ matrix.vsce_target }}-${{ env.EXT_VERSION }}.vsix";
await github.rest.repos.uploadReleaseAsset({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release.data.id,
data: fs.readFileSync(path),
name: "parallels-desktop-${{ matrix.vsce_target }}-${{ env.EXT_VERSION }}.vsix",
headers: {
"content-type": "application/vsix",
"content-length": fs.statSync(path).size
}
});
core.summary.addLink(`Release v${{ env.EXT_VERSION }}`, release.data.html_url);
await core.summary.write();
publish:
name: Publish extension v${{ needs.check-version-change.outputs.version }}
# environment: publish
needs:
- check-version-change
- upload-artifacts-to-release
runs-on: ubuntu-latest
permissions: {}
env:
EXT_VERSION: ${{ needs.check-version-change.outputs.version }}
steps:
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
- name: Publish Stable to Marketplace
run: npx vsce publish --no-git-tag-version --packagePath $(find . -iname *.vsix)
env:
VSCE_PAT: ${{ secrets.PUBLISHER_KEY }}