Skip to content

Commit 8558cc6

Browse files
Merge pull request #56 from commitd/sh/55
feat(ci): adds new release process
2 parents 7fcb03b + 472269a commit 8558cc6

File tree

13 files changed

+30965
-18797
lines changed

13 files changed

+30965
-18797
lines changed

.github/workflows/ci.yml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- beta
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
11+
concurrency:
12+
group: ${{ github.ref }}-${{ github.head_ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
NODE_VERSION: 16
17+
18+
jobs:
19+
install-cache:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout Commit
23+
uses: actions/checkout@v2
24+
with:
25+
fetch-depth: 0
26+
- name: Use Node.js
27+
uses: actions/setup-node@v1
28+
with:
29+
node-version: ${{ env.NODE_VERSION }}
30+
- name: Cache dependencies
31+
uses: actions/cache@v2
32+
id: cache-dependencies
33+
with:
34+
path: node_modules
35+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
36+
restore-keys: |
37+
${{ runner.os }}-npm-
38+
- name: Install Dependencies
39+
if: steps.cache-dependencies.outputs.cache-hit != 'true'
40+
run: |
41+
npm ci
42+
static-analysis:
43+
runs-on: ubuntu-latest
44+
needs: install-cache
45+
steps:
46+
- name: Checkout Commit
47+
uses: actions/checkout@v2
48+
with:
49+
fetch-depth: 0
50+
- name: Use Node.js
51+
uses: actions/setup-node@v1
52+
with:
53+
node-version: ${{ env.NODE_VERSION }}
54+
- name: Restore dependencies
55+
uses: actions/cache@v2
56+
id: cache-dependencies
57+
with:
58+
path: node_modules
59+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
60+
restore-keys: |
61+
${{ runner.os }}-npm-
62+
- name: Run prettier
63+
run: |
64+
npm run format:check
65+
build:
66+
runs-on: ubuntu-latest
67+
needs: install-cache
68+
steps:
69+
- name: Checkout Commit
70+
uses: actions/checkout@v2
71+
with:
72+
fetch-depth: 0
73+
- name: Use Node.js
74+
uses: actions/setup-node@v1
75+
with:
76+
node-version: ${{ env.NODE_VERSION }}
77+
- name: Restore dependencies
78+
uses: actions/cache@v2
79+
id: cache-dependencies
80+
with:
81+
path: node_modules
82+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
83+
restore-keys: |
84+
${{ runner.os }}-npm-
85+
- name: Cache gatsby dependencies
86+
uses: actions/cache@v2
87+
with:
88+
path: |
89+
example/.cache
90+
example/public
91+
key: ${{ runner.os }}-gatsby-${{ hashFiles('**/package-lock.json', '**/gatsby-node.js', '**/gatsby-config.js') }}
92+
- name: Run build
93+
run: |
94+
npm run build
95+
- name: Upload build artifacts
96+
uses: actions/upload-artifact@v2
97+
with:
98+
name: build-output
99+
path: example/public
100+
retention-days: 1
101+
release:
102+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta'
103+
runs-on: ubuntu-latest
104+
needs: [static-analysis, build]
105+
steps:
106+
- name: Checkout Commit
107+
uses: actions/checkout@v2
108+
with:
109+
token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
110+
- name: Use Node.js
111+
uses: actions/setup-node@v1
112+
with:
113+
node-version: ${{ env.NODE_VERSION }}
114+
- name: Restore dependencies
115+
uses: actions/cache@v2
116+
id: cache-dependencies
117+
with:
118+
path: node_modules
119+
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
120+
restore-keys: |
121+
${{ runner.os }}-npm-
122+
- name: Restore gatsby dependencies
123+
uses: actions/cache@v2
124+
with:
125+
path: |
126+
example/.cache
127+
example/public
128+
key: ${{ runner.os }}-gatsby-${{ hashFiles('**/package-lock.json', '**/gatsby-node.js', '**/gatsby-config.js') }}
129+
- name: Release
130+
env:
131+
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
132+
GIT_AUTHOR_NAME: commitd-bot
133+
GIT_AUTHOR_EMAIL: [email protected]
134+
GIT_COMMITTER_NAME: commitd-bot
135+
GIT_COMMITTER_EMAIL: [email protected]
136+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
137+
run: npx semantic-release
138+
working-directory: ./theme
139+
publish-docs:
140+
runs-on: ubuntu-latest
141+
needs: release
142+
steps:
143+
- name: Checkout Commit
144+
uses: actions/checkout@v2
145+
with:
146+
token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
147+
fetch-depth: 0
148+
- name: Use Node.js
149+
uses: actions/setup-node@v1
150+
with:
151+
node-version: ${{ env.NODE_VERSION }}
152+
- name: Download build artifacts
153+
uses: actions/download-artifact@v2
154+
with:
155+
name: build-output
156+
path: example/public
157+
- name: Publish Docs
158+
if: github.ref == 'refs/heads/main'
159+
run: npm run deploy:ci -w example
160+
env:
161+
GH_TOKEN: commitd-bot:${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}

.github/workflows/main.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/pr.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.husky/pre-push

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
. "$(dirname "$0")/_/husky.sh"
33

44
npm run format:check
5+
npm run build

.prettierignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.prettierignore
12
node_modules/
23
public/
3-
.cache/
4+
.cache/
5+
.husky/

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ On first use run
123123
npm install
124124
```
125125

126+
A standard set of support scripts are available throught the `package.json`.
127+
We use semantic-release with [conventional commits](https://www.conventionalcommits.org).
128+
Run `npm run commit` to help correctly form commit messages.
129+
126130
### Layout
127131

128132
A simplified layout is shown below

example/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "example",
3-
"version": "3.1.0",
3+
"version": "0.0.0-development",
44
"main": "index.js",
55
"author": "Committed <[email protected]>",
66
"license": "MIT",
@@ -11,10 +11,10 @@
1111
"build": "gatsby build --prefix-paths && cp ./README.md public/",
1212
"serve": "gatsby serve --prefix-paths",
1313
"deploy": "gh-pages -d public",
14-
"deploy:ci": "gh-pages -d public -f -u 'github-actions-bot <[email protected]>' -r https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
14+
"deploy:ci": "gh-pages -d public -f -u 'github-actions-bot <[email protected]>' -r https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
1515
},
1616
"dependencies": {
17-
"@committed/gatsby-theme-docs": "^3.0.0",
17+
"@committed/gatsby-theme-docs": "*",
1818
"gatsby": "^3.8.0",
1919
"gatsby-plugin-manifest": "^3.8.0",
2020
"react": "^17.0.2",

0 commit comments

Comments
 (0)