Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit 05bd2cd

Browse files
authored
ci: merge ci and release workflow (#37)
* refactor: update ci workflow * chore: remove old release workflow * chore: add missing tasks * fix: TS issue * chore: ignore vue TypeScript configuration issue * chore: update TS config * chore: add format and format:check scripts * chore: code style * fix: wrong test script * chore: add missing tsconfig * docs: remove release badge
1 parent 9e800f1 commit 05bd2cd

35 files changed

+478
-279
lines changed

.changeset/config.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3-
"changelog": "@changesets/cli/changelog",
4-
"commit": ["@changesets/cli/commit", { "skipCI": false }],
5-
"fixed": [],
6-
"linked": [],
7-
"access": "public",
8-
"baseBranch": "main",
9-
"updateInternalDependencies": "patch",
10-
"ignore": ["demo"]
11-
}
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": ["@changesets/cli/commit", { "skipCI": false }],
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": ["demo"]
11+
}

.github/workflows/ci.yml

+169-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,96 @@
11
name: CI
22

33
on:
4-
pull_request:
4+
push:
55
branches:
66
- main
7-
push:
7+
pull_request:
88
branches:
99
- main
1010

1111
jobs:
12-
lint:
12+
# Always use Node 20
13+
# Add Node 18 to the matrix if we’re in the release PR
14+
define-matrix:
15+
runs-on: ubuntu-latest
16+
17+
outputs:
18+
node-versions: ${{ steps.node-versions.outputs.node-versions }}
19+
20+
steps:
21+
- name: Node version matrix
22+
id: node-versions
23+
run: |
24+
if [ "${{ github.head_ref }}" == "changeset-release/main" ]; then
25+
echo 'node-versions=[18, 20]' >> "$GITHUB_OUTPUT"
26+
else
27+
echo 'node-versions=[20]' >> "$GITHUB_OUTPUT"
28+
fi
29+
- name: Print Node version matrix
30+
run: echo "node-versions=${{ steps.node-versions.outputs.node-versions }}"
31+
- name: Check Node version matrix
32+
run: |
33+
if [ "${{ steps.node-versions.outputs.node-versions }}" != "[18, 20]" ] && [ "${{ steps.node-versions.outputs.node-versions }}" != "[20]" ]; then
34+
echo "Node version matrix is not [18, 20] or [20]"
35+
exit 1
36+
fi
37+
38+
build:
39+
runs-on: ubuntu-20.04
40+
needs: define-matrix
41+
strategy:
42+
matrix:
43+
node-version: ${{ fromJSON(needs.define-matrix.outputs.node-versions) }}
44+
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: pnpm/action-setup@v4
48+
- name: Use Node.js ${{ matrix.node-version }}
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: ${{ matrix.node-version }}
52+
cache: 'pnpm'
53+
- name: Install dependencies
54+
run: pnpm install
55+
- name: Turborepo cache
56+
uses: actions/cache@v4
57+
with:
58+
path: .turbo
59+
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
60+
- name: Build
61+
run: pnpm turbo build
62+
- name: Update Turborepo cache
63+
uses: actions/cache/save@v4
64+
with:
65+
path: .turbo
66+
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
67+
68+
format:
1369
runs-on: ubuntu-20.04
1470
strategy:
1571
matrix:
1672
node-version: [20]
1773

74+
steps:
75+
- uses: actions/checkout@v4
76+
- uses: pnpm/action-setup@v4
77+
- name: Use Node.js ${{ matrix.node-version }}
78+
uses: actions/setup-node@v4
79+
with:
80+
node-version: ${{ matrix.node-version }}
81+
cache: 'pnpm'
82+
- name: Install dev dependencies
83+
run: pnpm install --dev
84+
- name: Check code style
85+
run: pnpm format:check
86+
87+
types:
88+
runs-on: ubuntu-20.04
89+
needs: [define-matrix, build]
90+
strategy:
91+
matrix:
92+
node-version: ${{ fromJSON(needs.define-matrix.outputs.node-versions) }}
93+
1894
steps:
1995
- uses: actions/checkout@v4
2096
- uses: pnpm/action-setup@v4
@@ -26,8 +102,94 @@ jobs:
26102
- name: Install dependencies
27103
run: pnpm install
28104
- name: Turborepo cache
29-
uses: dtinth/setup-github-actions-caching-for-turbo@v1
105+
uses: actions/cache/restore@v4
106+
with:
107+
path: .turbo
108+
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
109+
- name: Build
110+
run: pnpm turbo build
111+
- if: matrix.node-version == 20 || github.head_ref == 'changeset-release/main'
112+
name: Check types
113+
run: pnpm turbo types:check
114+
115+
test:
116+
runs-on: ubuntu-20.04
117+
needs: [define-matrix, build]
118+
strategy:
119+
matrix:
120+
node-version: ${{ fromJSON(needs.define-matrix.outputs.node-versions) }}
121+
122+
steps:
123+
- uses: actions/checkout@v4
124+
- uses: pnpm/action-setup@v4
125+
- name: Use Node.js ${{ matrix.node-version }}
126+
uses: actions/setup-node@v4
127+
with:
128+
node-version: ${{ matrix.node-version }}
129+
cache: 'pnpm'
130+
- name: Install dependencies
131+
run: pnpm install
132+
- name: Turborepo cache
133+
uses: actions/cache/restore@v4
134+
with:
135+
path: .turbo
136+
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
137+
- name: Build
138+
run: pnpm build
139+
- name: Run tests
140+
run: pnpm test
141+
142+
release:
143+
if: github.ref == 'refs/heads/main'
144+
runs-on: ubuntu-20.04
145+
permissions:
146+
contents: write
147+
id-token: write
148+
needs: [build, test]
149+
strategy:
150+
matrix:
151+
node-version: [20]
152+
153+
steps:
154+
- uses: actions/checkout@v4
155+
- uses: pnpm/action-setup@v4
156+
- name: Use Node.js ${{ matrix.node-version }}
157+
uses: actions/setup-node@v4
158+
with:
159+
node-version: ${{ matrix.node-version }}
160+
cache: 'pnpm'
161+
- name: Install dependencies
162+
run: pnpm install
163+
- name: Turborepo cache
164+
uses: actions/cache/restore@v4
165+
with:
166+
path: .turbo
167+
key: turbo-${{ runner.os }}-node-${{ matrix.node-version }}
168+
- name: Build
169+
run: pnpm turbo build
170+
- name: Git Status
171+
run: git status
172+
- name: Stash changes
173+
run: git stash
174+
- name: Create Release Pull Request or Publish to npm
175+
id: changesets
176+
uses: changesets/action@v1
30177
with:
31-
cache-prefix: snippetz
32-
- name: Build & test
33-
run: pnpm turbo test
178+
# The pull request title.
179+
title: 'chore: release'
180+
# The command to update version, edit CHANGELOG, read and delete changesets.
181+
version: 'pnpm changeset version'
182+
# The commit message to use.
183+
commit: 'chore: version packages'
184+
# The command to use to build and publish packages
185+
publish: 'pnpm -r publish --access public'
186+
env:
187+
# https://github.com/settings/tokens/new
188+
# Expiration: No expiration
189+
# Select: repo.*
190+
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
191+
# https://www.npmjs.com/settings/YOUR_ACCOUNT_HANDLE/tokens/granular-access-tokens/new
192+
# Custom Expiration: 01-01-2100
193+
# Permissions: Read and Write
194+
# Select packages: @scalar
195+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yml

-50
This file was deleted.

.prettierignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
**/.git
2+
**/.svn
3+
**/.hg
4+
**/node_modules
5+
**/dist/**
6+
**/.turbo/**
7+
**/build/**
8+
**/.next/**
9+
**/.nuxt/**
10+
11+
/venv/
12+
**/venv
13+
/.venv/
14+
**/.venv
15+
16+
pnpm-lock.yaml
17+
.changeset/*.md
18+
19+
.vite-ssg-temp
20+
.next

.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"tabWidth": 2,
44
"semi": false,
55
"singleQuote": true
6-
}
6+
}

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Snippetz
22

33
[![CI](https://github.com/scalar/snippetz/actions/workflows/ci.yml/badge.svg)](https://github.com/scalar/snippetz/actions/workflows/ci.yml)
4-
[![Release](https://github.com/scalar/snippetz/actions/workflows/release.yml/badge.svg)](https://github.com/scalar/snippetz/actions/workflows/release.yml)
54
[![Contributors](https://img.shields.io/github/contributors/scalar/snippetz)](https://github.com/scalar/snippetz/graphs/contributors)
65
[![GitHub License](https://img.shields.io/github/license/scalar/snippetz)](https://github.com/scalar/snippetz/blob/main/LICENSE)
76
[![Version](https://img.shields.io/npm/v/%40scalar/snippetz)](https://www.npmjs.com/package/@scalar/snippetz)
@@ -24,7 +23,7 @@ npm install @scalar/snippetz
2423
import { snippetz } from '@scalar/snippetz'
2524

2625
const snippet = snippetz().print('node', 'undici', {
27-
url: 'https://example.com'
26+
url: 'https://example.com',
2827
})
2928

3029
/* Output */
@@ -73,7 +72,7 @@ const snippet = snippetz().hasPlugin('node', 'undici')
7372
import { undici } from '@scalar/snippetz-plugin-undici'
7473

7574
const source = undici({
76-
url: 'https://example.com'
75+
url: 'https://example.com',
7776
})
7877

7978
console.log(source.code)
@@ -118,4 +117,4 @@ Contributions are welcome! Read [`CONTRIBUTING`](https://github.com/scalar/snipp
118117

119118
## License
120119

121-
The source code in this repository is licensed under [MIT](https://github.com/scalar/snippetz/blob/main/LICENSE).
120+
The source code in this repository is licensed under [MIT](https://github.com/scalar/snippetz/blob/main/LICENSE).

demo/index.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Snippetz / Opinionated HTTP Snippets</title>
7-
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌐</text></svg>">
7+
<link
8+
rel="icon"
9+
href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🌐</text></svg>"
10+
/>
811
</head>
912
<body>
1013
<div id="app"></div>

demo/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "vue-tsc && vite build",
9+
"types:build": "vue-tsc -p tsconfig.build.json",
10+
"types:check": "vue-tsc --composite false",
911
"preview": "vite preview"
1012
},
1113
"dependencies": {

0 commit comments

Comments
 (0)