Skip to content

chore: update CI workflow to pack plugin with custom output filename … #40

chore: update CI workflow to pack plugin with custom output filename …

chore: update CI workflow to pack plugin with custom output filename … #40

Workflow file for this run

name: Release
# This workflow will draft a release for a plugin when tagged. The tag format
# is <plugin-directory>/v<version> where plugin-directory is the exact directory
# name under plugins/, e.g.:
# - backstage-plugin-coder/v0.0.0
# - auth-backend-module-coder-provider/v0.0.0
# - backstage-plugin-devcontainers-backend/v0.0.0
on:
push:
tags:
- '*/v*'
permissions:
contents: write # For creating releases.
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
split-tag:
runs-on: ubuntu-latest
outputs:
plugin: ${{ steps.split.outputs.plugin }}
version: ${{ steps.split.outputs.version }}
steps:
- uses: actions/checkout@v4
- env:
TAG: ${{ github.ref_name }}
id: split
run: |
parts=(${TAG//\/v/ })
PLUGIN_NAME="${parts[0]}"
VERSION="${parts[1]}"
if [[ ! -d "plugins/${PLUGIN_NAME}" ]]; then
echo "Error: Plugin directory 'plugins/${PLUGIN_NAME}' not found"
echo "Tag should match the exact directory name in plugins/"
exit 1
fi
echo "plugin=${PLUGIN_NAME}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Plugin: ${PLUGIN_NAME}"
echo "Version: ${VERSION}"
plugin:
needs: split-tag
runs-on: ubuntu-latest
defaults:
run:
working-directory: plugins/${{ needs.split-tag.outputs.plugin }}
name: ${{ needs.split-tag.outputs.plugin }} v${{ needs.split-tag.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: yarn
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn test
- run: yarn tsc
working-directory: ${{ github.workspace }}
- run: yarn build
# Version it with the version in the tag and upload it to a draft release.
- name: Set version
run: |
node -e "const fs=require('fs'); const pkg=JSON.parse(fs.readFileSync('package.json')); pkg.version='${{ needs.split-tag.outputs.version }}'; fs.writeFileSync('package.json', JSON.stringify(pkg,null,2)+'\n');"
echo "Set version to ${{ needs.split-tag.outputs.version }}"
- name: Pack plugin
run: yarn pack --out '%s-%v.tgz'
- uses: softprops/action-gh-release@v2
with:
draft: true
files: plugins/${{ needs.split-tag.outputs.plugin }}/*.tgz