Skip to content

Release

Release #20

Workflow file for this run

---
name: Release
on:
workflow_dispatch:
inputs:
title:
description: "Release title (leave blank for tag)"
required: false
jobs:
prepare:
runs-on: ubuntu-latest
name: Prepare project for deployment
outputs:
new_version: ${{ steps.bumper.outputs.new_version }}
release_name: ${{ steps.release_name.outputs.value }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
ssh-key: ${{ secrets.DEPLOY_KEY }}
- name: Determine next SemVer
id: bumper
uses: tomerfi/[email protected]
- name: Create a release name
id: release_name
uses: actions/github-script@v7
with:
script: |
var retval = '${{ steps.bumper.outputs.next }}'
if ('${{ github.event.inputs.title }}') {
retval = retval.concat(' - ${{ github.event.inputs.title }}')
}
core.setOutput('value', retval)
- name: Update package with new version
run: |
npm version ${{ steps.bumper.outputs.next }} --no-git-tag-version
- name: Configure git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Commit and push package modifications
run: |
git add package.json
git add package-lock.json
git commit -m "docs: updated package with ${{ steps.bumper.outputs.next }} [skip ci]"
git push
package:
needs: prepare
strategy:
matrix:
include:
- os: macos-latest
targets: "darwin-x64,darwin-arm64"
- os: ubuntu-latest
targets: "linux-x64,linux-arm64"
- os: windows-latest
targets: "win32-x64"
name: Create a VSIX package for targets [ ${{ matrix.targets }} ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Pull default branch from remote
run: git pull origin ${{ github.event.repository.default_branch }}
- name: Install node 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Install project modules
run: npm ci
- name: Create a VSIX package for targets [ ${{ matrix.targets }} ]
shell: bash
run: >
echo "${{ matrix.targets }}" | tr "," "\n" | while read -r target; do
npm run vsce:package -- \
--target ${target} \
--out ocm-vscode-extension-${target}-${{ needs.prepare.outputs.new_version }}.vsix
done
- name: Upload VSIX package as artifact
uses: actions/upload-artifact@v4
with:
name: vsix-${{ matrix.os }}
path: ./*.vsix
release:
runs-on: ubuntu-latest
name: Create a release
needs: [package, prepare]
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.OCM_BOT_PAT }}
- name: Install node 20
uses: actions/setup-node@v4
with:
node-version: '20'
cache: npm
- name: Install project modules
run: npm ci
- name: Download VSIX package artifacts
uses: actions/download-artifact@v4
with:
path: ./vsix
- name: Create a new release
id: new_release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.OCM_BOT_PAT }}
script: |
const repo_name = context.payload.repository.full_name
const response = await github.request('POST /repos/' + repo_name + '/releases', {
tag_name: '${{ needs.prepare.outputs.new_version }}',
name: '${{ needs.prepare.outputs.release_name }}',
generate_release_notes: true
})
core.setOutput('upload_url', response.data.upload_url)
- name: Create SHA256 checksums for the VSIX packages
working-directory: vsix
run: |
for pkg in ./**/*.vsix
do
sha_file=$(echo $pkg | sed 's/\.vsix/\.sha256/g')
sha256sum $pkg > $sha_file
done
- name: Upload packages and checksums as EA release assets
working-directory: vsix
run: |
for file in ./**/*.{vsix,sha256}
do
asset_name=$(basename $file)
upload_url=$(echo "${{ steps.new_release.outputs.upload_url }}" | sed "s/{?name,label}/?name=$asset_name/g")
curl --data-binary @"$file" \
-H "Authorization: token ${{ secrets.OCM_BOT_PAT }}" \
-H "Content-Type: application/octet-stream" \
$upload_url
done
- name: Publish VSIX packages to the marketplace
run: >
npm run vsce:publish --
--pat ${{ secrets.VSCE_PAT }}
--packagePath $(find ./vsix -iname *.vsix)