Skip to content

Stage

Stage #40

Workflow file for this run

---
name: Stage
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- ".github/**"
jobs:
package:
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: 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 -- \
--pre-release --target ${target} \
--out ocm-vscode-extension-${target}-early-access.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 an Early-access release
if: github.repository_owner == 'open-cluster-management-io'
needs: package
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.OCM_BOT_PAT }}
- name: Download VSIX package artifacts
uses: actions/download-artifact@v4
with:
path: ./vsix
- name: Check for existing EA release
id: existing_release
uses: actions/github-script@v7
continue-on-error: true
with:
github-token: ${{ secrets.OCM_BOT_PAT }}
script: |
const repo_name = context.payload.repository.full_name
var response = await github.request('GET /repos/' + repo_name + '/releases/tags/early-access')
// if the request fails (ie 404) the next steps will not occur and the output will not be set
core.setOutput('id', response.data.id)
- name: Delete EA release if exists
if: ${{ steps.existing_release.outputs.id }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.OCM_BOT_PAT }}
script: |
const repo_name = context.payload.repository.full_name
await github.request('DELETE /repos/' + repo_name + '/releases/' + ${{ steps.existing_release.outputs.id }})
- name: Delete EA tag if exists
continue-on-error: true
run: git push --delete origin early-access
# a little pause between deleting the release and creating a new one
# without it, the new release might be a weird release, i.e. a draft release which is not deleted with the previous step
- name: Sleep 5
run: sleep 5
- name: Create new EA 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: 'early-access',
name: 'Early-access',
prerelease: true,
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