♻️ Refactor before adding subcommands #77
Workflow file for this run
This file contains 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: 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: | |
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 | |
- name: CI build | |
run: npm run ci-build | |
Test: | |
name: Test (${{ matrix.node }} | ${{ matrix.platform.os }}) | |
defaults: | |
run: | |
shell: bash | |
runs-on: ${{ matrix.platform.os }}-latest | |
strategy: | |
matrix: | |
node: | |
- 20.x | |
- 22.x | |
platform: | |
- os: ubuntu | |
- os: macos | |
- os: windows | |
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 | |
run: npm install | |
- name: Build | |
run: npm run build | |
- name: "Test 1: default case" | |
run: | | |
scripts/test.sh foo '' '*.css' | |
- name: "Test 2: localsConvention, first position" | |
if: success() || failure() | |
run: | | |
scripts/test.sh casing/casing '' '--localsConvention camelCaseOnly *.css' casing/camelCaseOnly | |
- name: "Test 3: localsConvention, second position" | |
if: success() || failure() | |
run: | | |
scripts/test.sh casing/casing '' '*.css --localsConvention camelCaseOnly' casing/camelCaseOnly | |
- name: "Test 4: relative outdir" | |
if: success() || failure() | |
run: | | |
scripts/test.sh foo '' '--outdir generated *.css' '' generated/ | |
- name: "Test 5: absolute outdir" | |
if: success() || failure() | |
run: | | |
scripts/test.sh foo "" "-o $GITHUB_WORKSPACE/generated *.css" "" "$GITHUB_WORKSPACE"/generated/ | |
# Note: This test uses double quotes, which expands differently. | |
- name: "Test 6: json file config" | |
if: success() || failure() | |
run: | | |
scripts/test.sh foo csstypedrc.json | |
- name: "Test 7: yaml file config" | |
if: success() || failure() | |
run: | | |
scripts/test.sh foo csstypedrc.yaml '' '' generated/ | |
- name: "Test 8: custom config path" | |
if: success() || failure() | |
run: | | |
scripts/test.sh foo css-typed-rc.yaml '-c .config/css-typed-rc.yaml' | |
- name: "Test 9: mjs file config" | |
if: matrix.platform.os != 'windows' && (success() || failure()) | |
# Do not run on Windows due to Windows-only ESM import bug. | |
# This _could_ be an issue with css-typed, but could be a test/deps issue. | |
run: | | |
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 | |
needs: | |
- Build # For version variable | |
- Test # Requires passing tests | |
runs-on: ubuntu-latest | |
env: | |
GitVersion_SemVer: ${{needs.Build.outputs.GitVersion_SemVer}} | |
permissions: | |
contents: write | |
id-token: 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 install | |
- name: Publish | |
run: npm publish --provenance --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: git tag | |
run: | | |
git tag v${{ env.GitVersion_SemVer }} | |
git push origin tag v${{ env.GitVersion_SemVer }} |