73 lines
2.3 KiB
YAML
73 lines
2.3 KiB
YAML
name: Publish Package
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
package:
|
|
description: 'Package directory to publish (e.g., packages/sse-client)'
|
|
required: true
|
|
version_bump:
|
|
description: 'Version bump (patch, minor, major, none, or version:x.y.z)'
|
|
required: true
|
|
default: 'patch'
|
|
type: 'string'
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Set up PNPM
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
|
|
- name: Set up SSH key
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "${{ secrets.GITEA_DEPLOY_KEY }}" > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
ssh-keyscan git.generation.one >> ~/.ssh/known_hosts
|
|
|
|
- name: Set up Git
|
|
run: |
|
|
git config --global user.name "GitHub Actions"
|
|
git config --global user.email "actions@github.com"
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Publish package
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
echo "@g1:registry=https://git.generation.one/api/packages/GenerationOne/npm/" > .npmrc
|
|
echo "//git.generation.one/api/packages/GenerationOne/npm/:_authToken=${GITEA_TOKEN}" >> .npmrc
|
|
echo "legacy-peer-deps=true" >> .npmrc
|
|
echo "resolution-mode=highest" >> .npmrc
|
|
|
|
cd ${{ github.event.inputs.package }}
|
|
|
|
if [ "${{ github.event.inputs.version_bump }}" != "none" ]; then
|
|
# Check if it's a specific version (format: version:x.y.z)
|
|
if [[ "${{ github.event.inputs.version_bump }}" == version:* ]]; then
|
|
SPECIFIC_VERSION="${{ github.event.inputs.version_bump }}"
|
|
SPECIFIC_VERSION="${SPECIFIC_VERSION#version:}"
|
|
echo "Setting specific version ($SPECIFIC_VERSION)..."
|
|
npm version "$SPECIFIC_VERSION" --no-git-tag-version --allow-same-version
|
|
else
|
|
echo "Bumping version (${{ github.event.inputs.version_bump }})..."
|
|
npm version ${{ github.event.inputs.version_bump }} --no-git-tag-version
|
|
fi
|
|
fi
|
|
|
|
pnpm build
|
|
pnpm publish --no-git-checks
|