fix(contractor-onboarding) - move to latest step when the employment.… #635
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ inputs.ref || '' }} | |
| - name: Setup Node.js 24.x | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install dependencies | |
| run: npm ci --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 | |
| - 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 | |
| - 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 | |
| - name: Create git tag | |
| if: steps.version-check.outputs.changed == 'true' | |
| run: | | |
| git tag v${{ steps.version-check.outputs.version }} | |
| git push origin v${{ steps.version-check.outputs.version }} | |
| - 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" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: No release needed | |
| if: steps.version-check.outputs.changed == 'false' | |
| run: | | |
| echo "No version change detected. Skipping release." |