Skip to content

πŸš€ Continuous deployment #1

πŸš€ Continuous deployment

πŸš€ Continuous deployment #1

Workflow file for this run

name: Pipeline
on:
push:
branches: [main]
pull_request:
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:
useConfigFile: true
- name: Use Node.js
uses: actions/setup-node@v4
with:
cache: npm
node-version-file: .node-version
- name: Install
run: npm ci
- name: CI build
run: npm run ci-build
Test:
name: Test (${{ matrix.node }} | ${{ matrix.platform.os }})
needs: Build # Verify ci-build first
defaults:
run:
shell: bash
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
node:
- 20.x
- 22.x
platform:
- os: ubuntu-latest
- os: macos-latest
- os: windows-latest
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v4
with:
cache: npm
node-version: ${{ matrix.node }}
- name: Install production
run: npm i --include prod
- name: Build production
run: npm run build
- name: Run css-typed (the test)
# `node dist/main.js` is executing local `css-typed` as if installed (same as `bin`)
# Use `-I '//.*'` to ignore the first line (comment) which has generated path and timestamp
run: |
cp src/fixtures/kebab-case/kebab-case.css "$RUNNER_TEMP/kebab-case.css"
node dist/main.js "$RUNNER_TEMP/*.css"
diff --strip-trailing-cr -uI '//.*' src/fixtures/kebab-case/kebab-case-default.d.css.ts "$RUNNER_TEMP/kebab-case.d.css.ts"
node dist/main.js "$RUNNER_TEMP/*.css" --dashes
diff --strip-trailing-cr -uI '//.*' src/fixtures/kebab-case/kebab-case-dashes.d.css.ts "$RUNNER_TEMP/kebab-case.d.css.ts"
Publish:
# if: ${{ github.ref == 'refs/heads/main' }}
name: Publish
needs:
- Build # For version variable
- Test # Requires passing tests
runs-on: ubuntu-latest
env:
GitVersion_SemVer: ${{needs.Build.outputs.GitVersion_SemVer}}
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
cache: npm
node-version-file: .node-version
registry-url: https://registry.npmjs.org
- name: Set version
run: sed -i 's/0.0.0-gitversion/${{ env.GitVersion_SemVer }}/g' package.json
- name: Install
run: npm i --include prod
- name: Publish
run: npm publish --provenance --access public --dryrun
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}