Skip to content

Commit 193962d

Browse files
authored
πŸš€ Continuous deployment (#15)
Sets up continuous deployment with GitVersion. Renames `ci` to `pipeline` to match the mental model. Update contributing docs.
1 parent 24523d0 commit 193962d

File tree

5 files changed

+65
-11
lines changed

5 files changed

+65
-11
lines changed

β€Ž.github/workflows/ci.yaml β€Ž.github/workflows/pipeline.yaml

+56-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Pipeline
22

33
on:
44
push:
@@ -10,9 +10,24 @@ jobs:
1010
Build:
1111
name: Build
1212
runs-on: ubuntu-latest
13+
outputs:
14+
GitVersion_SemVer: ${{ steps.GitVersion.outputs.GitVersion_SemVer }}
1315
steps:
1416
- name: Checkout
1517
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Full depth (not shallow) for GitVersion and better relevancy of Sonar analysis
20+
21+
- name: Set up GitVersion
22+
uses: gittools/actions/gitversion/[email protected]
23+
with:
24+
versionSpec: 6.x
25+
26+
- name: Execute GitVersion
27+
id: GitVersion
28+
uses: gittools/actions/gitversion/[email protected]
29+
with:
30+
useConfigFile: true
1631

1732
- name: Use Node.js
1833
uses: actions/setup-node@v4
@@ -54,10 +69,10 @@ jobs:
5469
cache: npm
5570
node-version: ${{ matrix.node }}
5671

57-
- name: Install production
58-
run: npm ci --include prod
72+
- name: Install
73+
run: npm install --omit=dev
5974

60-
- name: Build production
75+
- name: Build
6176
run: npm run build
6277

6378
- name: Run css-typed (the test)
@@ -71,3 +86,40 @@ jobs:
7186
7287
node dist/main.js "$RUNNER_TEMP/*.css" --dashes
7388
diff --strip-trailing-cr -uI '//.*' src/fixtures/kebab-case/kebab-case-dashes.d.css.ts "$RUNNER_TEMP/kebab-case.d.css.ts"
89+
90+
Publish:
91+
if: ${{ github.ref == 'refs/heads/main' }}
92+
name: Publish
93+
needs:
94+
- Build # For version variable
95+
- Test # Requires passing tests
96+
runs-on: ubuntu-latest
97+
env:
98+
GitVersion_SemVer: ${{needs.Build.outputs.GitVersion_SemVer}}
99+
permissions:
100+
contents: write
101+
id-token: write
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- uses: actions/setup-node@v4
106+
with:
107+
cache: npm
108+
node-version-file: .node-version
109+
registry-url: https://registry.npmjs.org
110+
111+
- name: Set version
112+
run: sed -i 's/0.0.0-gitversion/${{ env.GitVersion_SemVer }}/g' package.json
113+
114+
- name: Install
115+
run: npm install --omit=dev
116+
117+
- name: Publish
118+
run: npm publish --provenance --access public
119+
env:
120+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
121+
122+
- name: git tag
123+
run: |
124+
git tag v${{ env.GitVersion_SemVer }}
125+
git push origin tag v${{ env.GitVersion_SemVer }}

β€ŽCONTRIBUTING.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ All contributions MUST adhere to the following expectations.
3030

3131
1. Every change MUST have unit tests.
3232
2. Every change MUST have a GitHub issue linked.
33-
3. Any configuration option change MUST be discussed in a GitHub issue first.
34-
4. I will squash-merge the changeset into `main` upon approval.
35-
5. I will publish the new version upon approval (not yet automated).
33+
3. Any configuration option change SHOULD be discussed in a GitHub issue first.
34+
4. The PR build (see [pipeline.yaml](./.github/workflows/pipeline.yaml)) MUST succeed.
35+
5. I will squash-merge the changeset into `main` upon approval.
3636

3737
[RFC2119]: https://www.rfc-editor.org/rfc/rfc2119
3838
[RFC8174]: https://www.rfc-editor.org/rfc/rfc8174

β€ŽGitVersion.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
workflow: GitHubFlow/v1
2+
mode: ContinuousDeployment

β€Žpackage-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-typed",
3-
"version": "0.2.4",
3+
"version": "0.0.0-gitversion",
44
"description": "Basic TypeScript declaration generator for CSS files",
55
"keywords": [
66
"CSS",
@@ -37,7 +37,7 @@
3737
"ci-build": "npm-run-all -l -p build eslint prettier test",
3838
"eslint": "eslint -f pretty .",
3939
"eslint:fix": "npm run eslint -- --fix",
40-
"prepublishOnly": "npm run ci-build",
40+
"prepublishOnly": "npm run build",
4141
"prettier": "prettier -c '**/*.{cjs,css,js,json,md,yaml,yml}'",
4242
"prettier:fix": "npm run prettier -- -w",
4343
"test": "vitest run"

0 commit comments

Comments
Β (0)