Skip to content

feat(ci): adds new release process #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 161 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: ci

on:
push:
branches:
- main
- beta
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: true

env:
NODE_VERSION: 16

jobs:
install-cache:
runs-on: ubuntu-latest
steps:
- name: Checkout Commit
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache dependencies
uses: actions/cache@v2
id: cache-dependencies
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install Dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
npm ci
static-analysis:
runs-on: ubuntu-latest
needs: install-cache
steps:
- name: Checkout Commit
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore dependencies
uses: actions/cache@v2
id: cache-dependencies
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Run prettier
run: |
npm run format:check
build:
runs-on: ubuntu-latest
needs: install-cache
steps:
- name: Checkout Commit
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore dependencies
uses: actions/cache@v2
id: cache-dependencies
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Cache gatsby dependencies
uses: actions/cache@v2
with:
path: |
example/.cache
example/public
key: ${{ runner.os }}-gatsby-${{ hashFiles('**/package-lock.json', '**/gatsby-node.js', '**/gatsby-config.js') }}
- name: Run build
run: |
npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v2
with:
name: build-output
path: example/public
retention-days: 1
release:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/beta'
runs-on: ubuntu-latest
needs: [static-analysis, build]
steps:
- name: Checkout Commit
uses: actions/checkout@v2
with:
token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Restore dependencies
uses: actions/cache@v2
id: cache-dependencies
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Restore gatsby dependencies
uses: actions/cache@v2
with:
path: |
example/.cache
example/public
key: ${{ runner.os }}-gatsby-${{ hashFiles('**/package-lock.json', '**/gatsby-node.js', '**/gatsby-config.js') }}
- name: Release
env:
GH_TOKEN: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
GIT_AUTHOR_NAME: commitd-bot
GIT_AUTHOR_EMAIL: 56758001+committed-bot@users.noreply.github.com
GIT_COMMITTER_NAME: commitd-bot
GIT_COMMITTER_EMAIL: 56758001+commitd-bot@users.noreply.github.com
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
working-directory: ./theme
publish-docs:
runs-on: ubuntu-latest
needs: release
steps:
- name: Checkout Commit
uses: actions/checkout@v2
with:
token: ${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: build-output
path: example/public
- name: Publish Docs
if: github.ref == 'refs/heads/main'
run: npm run deploy:ci -w example
env:
GH_TOKEN: commitd-bot:${{ secrets.SEMANTIC_RELEASE_GITHUB_TOKEN }}
45 changes: 0 additions & 45 deletions .github/workflows/main.yml

This file was deleted.

43 changes: 0 additions & 43 deletions .github/workflows/pr.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/publish.yml

This file was deleted.

1 change: 1 addition & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
. "$(dirname "$0")/_/husky.sh"

npm run format:check
npm run build
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.prettierignore
node_modules/
public/
.cache/
.cache/
.husky/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ On first use run
npm install
```

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

### Layout

A simplified layout is shown below
Expand Down
6 changes: 3 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "example",
"version": "3.1.0",
"version": "0.0.0-development",
"main": "index.js",
"author": "Committed <opensource@committed.io>",
"license": "MIT",
Expand All @@ -11,10 +11,10 @@
"build": "gatsby build --prefix-paths && cp ./README.md public/",
"serve": "gatsby serve --prefix-paths",
"deploy": "gh-pages -d public",
"deploy:ci": "gh-pages -d public -f -u 'github-actions-bot <support+actions@github.com>' -r https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
"deploy:ci": "gh-pages -d public -f -u 'github-actions-bot <support+actions@github.com>' -r https://${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
},
"dependencies": {
"@committed/gatsby-theme-docs": "^3.0.0",
"@committed/gatsby-theme-docs": "*",
"gatsby": "^3.8.0",
"gatsby-plugin-manifest": "^3.8.0",
"react": "^17.0.2",
Expand Down
Loading