Skip to content

1.49.0 (#1266)

1.49.0 (#1266) #1005

Workflow file for this run

name: Release
on:
push:
branches: [main]
workflow_dispatch:
inputs:
ref:
description: 'Branch or tag to release (e.g., release/0.28.1)'
required: true
type: string
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout Repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
ref: ${{ inputs.ref || '' }}
persist-credentials: false
- name: Setup Node.js 24.x
uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: '24.15.0'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci --include=optional --ignore-scripts
- name: Check if version changed
id: version-check
run: |
# Get current version from package.json
CURRENT_VERSION=$(node -p "require('./package.json').version")
# Check if this is a manual dispatch with ref input
if [ -n "${INPUTS_REF}" ]; then
echo "Manual release triggered for ref: ${INPUTS_REF}"
echo "changed=true" >> $GITHUB_OUTPUT
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Version to release: $CURRENT_VERSION"
else
# Normal flow: compare with last tag
# Get last tag
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
LAST_VERSION=${LAST_TAG#v}
echo "Current version: $CURRENT_VERSION"
echo "Last released version: $LAST_VERSION"
if [ "$CURRENT_VERSION" != "$LAST_VERSION" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Version changed from $LAST_VERSION to $CURRENT_VERSION"
else
echo "changed=false" >> $GITHUB_OUTPUT
echo "No version change detected"
fi
fi
env:
INPUTS_REF: ${{ inputs.ref }}
- name: Build and test
if: steps.version-check.outputs.changed == 'true'
run: |
npm run build
npm run test
- name: Determine npm tag
if: steps.version-check.outputs.changed == 'true'
id: npm-tag
run: |
CURRENT_VERSION="${STEPS_VERSION_CHECK_OUTPUTS_VERSION}"
# Get the latest version from npm registry
LATEST_VERSION=$(npm view @remoteoss/remote-flows dist-tags.latest 2>/dev/null || echo "0.0.0")
echo "Current version to publish: $CURRENT_VERSION"
echo "Latest version on npm: $LATEST_VERSION"
# Compare versions using sort -V (version sort)
# If current version is less than latest, use legacy tag
if [ "$(printf '%s\n' "$CURRENT_VERSION" "$LATEST_VERSION" | sort -V | head -n1)" = "$CURRENT_VERSION" ] && [ "$CURRENT_VERSION" != "$LATEST_VERSION" ]; then
echo "tag=legacy" >> $GITHUB_OUTPUT
echo "Publishing with --tag legacy (older than current latest)"
else
echo "tag=" >> $GITHUB_OUTPUT
echo "Publishing with default tag (will become latest)"
fi
env:
STEPS_VERSION_CHECK_OUTPUTS_VERSION: ${{ steps.version-check.outputs.version }}
- name: Publish to npm
if: steps.version-check.outputs.changed == 'true'
run: |
if [ -n "${STEPS_NPM_TAG_OUTPUTS_TAG}" ]; then
npm publish --provenance --access public --tag ${STEPS_NPM_TAG_OUTPUTS_TAG}
else
npm publish --provenance --access public
fi
env:
STEPS_NPM_TAG_OUTPUTS_TAG: ${{ steps.npm-tag.outputs.tag }}
- name: Create GitHub release
if: steps.version-check.outputs.changed == 'true'
run: |
# Get the changelog content for this version
CHANGELOG_CONTENT=$(awk '/^## [0-9]/ {if (p) exit} /^## '"${STEPS_VERSION_CHECK_OUTPUTS_VERSION}"'$/ {p=1; next} p' CHANGELOG.md)
gh release create v${STEPS_VERSION_CHECK_OUTPUTS_VERSION} \
--title "v${STEPS_VERSION_CHECK_OUTPUTS_VERSION}" \
--notes "$CHANGELOG_CONTENT" \
--target "$(git rev-parse HEAD)"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
STEPS_VERSION_CHECK_OUTPUTS_VERSION: ${{ steps.version-check.outputs.version }}
- name: No release needed
if: steps.version-check.outputs.changed == 'false'
run: |
echo "No version change detected. Skipping release."