Skip to content

Commit

Permalink
Merge pull request #1260 from finos/fix-build-and-publish-workflow-on…
Browse files Browse the repository at this point in the history
…-main

Fix build and publish workflow on main
  • Loading branch information
kriswest authored Jul 12, 2024
2 parents fdf060f + 4c2fd3c commit 5279be3
Showing 1 changed file with 43 additions and 20 deletions.
63 changes: 43 additions & 20 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,44 @@ on:
- release/**
paths-ignore:
- '.github/workflows/docusaurus.yml'
- 'docs/**'
- 'website/**'
pull_request:
types: [opened, reopened, edited, ready_for_review]
branches:
- main
- release/*
- release/**
paths-ignore:
- '.github/workflows/docusaurus.yml'
- 'docs/**'
- 'website/**'
permissions:
contents: read

jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
# Set job outputs to values from the filter step
outputs:
builtFiles: ${{ steps.filter.outputs.builtFiles }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 #v3.0.2
id: filter
with:
filters: |
builtFiles:
- '.eslint*'
- 'src/**'
- 'schemas/**'
- 'package-lock.json'
- 'package.json'
- 'rollup.config.js'
- 's2tQuicktypeUtil.js'
- 'tsconfig.json'
- '.github/workflows/package.yml'
package-build:
name: Build on Node ${{ matrix.node }} and ${{ matrix.os }}

needs: changes
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -39,28 +59,39 @@ jobs:

steps:
- name: Checkout repo
if: ${{ needs.changes.outputs.builtFiles == 'true' }}
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Use Node ${{ matrix.node }}
if: ${{ needs.changes.outputs.builtFiles == 'true' }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
if: ${{ needs.changes.outputs.builtFiles == 'true' }}
uses: bahmutov/npm-install@2509f13e8485d88340a789a3f7ca11aaac47c9fc #v1.8.36

- name: Lint
if: ${{ needs.changes.outputs.builtFiles == 'true' }}
run: npm run lint

- name: Test
if: ${{ needs.changes.outputs.builtFiles == 'true' }}
run: npm run test --ci --coverage --maxWorkers=2

- name: Build
if: ${{ needs.changes.outputs.builtFiles == 'true' }}
run: npm run build

- name: Checkout repo
if: ${{ needs.changes.outputs.builtFiles == 'false' }}
run: 'echo "Build steps skipped as no relevant changes were detected"'


package-publish:
if: ${{ github.event_name == 'push' }}
needs: package-build
if: ${{ github.event_name == 'push' && needs.changes.outputs.builtFiles == 'true'}}
needs: [changes,package-build]
name: Publish package to ${{ matrix.name }}
runs-on: ubuntu-latest
permissions:
Expand Down Expand Up @@ -89,22 +120,14 @@ jobs:
- name: Check package version
id: check-version
uses: tehpsalmist/npm-publish-status-action@deb911186cfe5134094f49183364da10a986e4e7

# Disabled when switching from PostHog/check-package-version as the new lib
# just tells you if your version exists or not
# - name: Package version info
# run: |
# echo "Committed version: ${{ steps.check-version.outputs.committed-version }}"
# echo "Published version: ${{ steps.check-version.published-version }}"
# echo "Is version new: ${{ steps.check-version.outputs.is-new-version }}"


- name: Report already published status
if: steps.check-version.outputs.exists == '1'
run: 'echo "package version already exists on npm registry"'
run: 'echo "package version already exists in the NPM registry"'

- name: Report not yet published status
if: steps.check-version.outputs.exists == '0'
run: 'echo "package version does not exist on npm registry, publishing..."'
run: 'echo "package version does not exist in the NPM registry, publishing..."'

- name: Install dependencies
if: steps.check-version.outputs.exists == '0'
Expand Down

0 comments on commit 5279be3

Please sign in to comment.