Skip to content
56 changes: 12 additions & 44 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,11 @@ on:
branches: [main]

jobs:
Build:
name: Build
runs-on: ubuntu-latest
outputs:
GitVersion_SemVer: ${{ steps.GitVersion.outputs.GitVersion_SemVer }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full depth (not shallow) for GitVersion and better relevancy of Sonar analysis

- name: Set up GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: 6.x

- name: Execute GitVersion
id: GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
overrideConfig: |
workflow=GitHubFlow/v1
mode=ContinuousDeployment

- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: .node-version

- name: Install
run: npm ci
CiBuild:
name: CI Build
uses: connorjs/github-workflows/.github/workflows/npm-ci-build~v1.yaml@main

- name: CI build
run: npm run ci-build

Test:
PipelineTests:
name: Test (${{ matrix.node }} | ${{ matrix.platform.os }})
defaults:
run:
Expand Down Expand Up @@ -124,14 +92,14 @@ jobs:
scripts/test.sh foo custom-config-path.config.mjs '-c .config/custom-config-path.config.mjs'

Publish:
if: ${{ github.ref == 'refs/heads/main' }}
name: Publish
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- Build # For version variable
- Test # Requires passing tests
- CiBuild # For version variable
- PipelineTests # Requires passing tests
runs-on: ubuntu-latest
env:
GitVersion_SemVer: ${{needs.Build.outputs.GitVersion_SemVer}}
semVer: ${{needs.CiBuild.outputs.semVer}}
permissions:
contents: write
id-token: write
Expand All @@ -145,10 +113,10 @@ jobs:
registry-url: https://registry.npmjs.org

- name: Set version
run: sed -i 's/0.0.0-gitversion/${{ env.GitVersion_SemVer }}/g' package.json
run: sed -i 's/0.0.0-gitversion/${{ env.semVer }}/g' package.json

- name: Install
run: npm install
run: npm ci

- name: Publish
run: npm publish --provenance --access public
Expand All @@ -157,5 +125,5 @@ jobs:

- name: git tag
run: |
git tag v${{ env.GitVersion_SemVer }}
git push origin tag v${{ env.GitVersion_SemVer }}
git tag v${{ env.semVer }}
git push origin tag v${{ env.semVer }}