Skip to content

Commit 469d1c8

Browse files
committed
update ci so it makes/publishes when version is updated
1 parent fe5d065 commit 469d1c8

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
permissions:
10+
contents: write
11+
912
jobs:
1013
build:
1114
runs-on: windows-latest
1215

1316
steps:
1417
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 2 # Fetch the last 2 commits to compare changes
1520

1621
- name: Setup Node.js
1722
uses: actions/setup-node@v4
@@ -51,17 +56,34 @@ jobs:
5156
- name: Run tests with coverage
5257
run: npm test
5358

59+
- name: Upload coverage report
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: coverage-report
63+
path: coverage
64+
65+
- name: Check if version changed
66+
id: check_version
67+
shell: pwsh
68+
run: |
69+
$currentVersion = (Get-Content package.json | ConvertFrom-Json).version
70+
$previousVersion = (git show HEAD^:package.json | ConvertFrom-Json).version
71+
if ($currentVersion -ne $previousVersion) {
72+
echo "version_changed=true" >> $env:GITHUB_OUTPUT
73+
echo "Version changed from $previousVersion to $currentVersion"
74+
}
75+
5476
- name: Generate assets
77+
if: steps.check_version.outputs.version_changed == 'true'
5578
run: npm run generate-assets
5679
env:
5780
IRACING_USERNAME: ${{ secrets.IRACING_USERNAME }}
5881
IRACING_PASSWORD: ${{ secrets.IRACING_PASSWORD }}
5982

60-
- name: Upload coverage report
61-
uses: actions/upload-artifact@v4
62-
with:
63-
name: coverage-report
64-
path: coverage
83+
- name: Make
84+
if: steps.check_version.outputs.version_changed == 'true'
85+
run: npm run make
6586

66-
- name: Package
67-
run: npm run package
87+
- name: Publish
88+
if: steps.check_version.outputs.version_changed == 'true'
89+
run: npm run publish

0 commit comments

Comments
 (0)