Skip to content

Commit

Permalink
feat(nx-plugin): Release automation (#129)
Browse files Browse the repository at this point in the history
* Set up release-please and clean up workflows
* Remove extra whitespace caused by generator templates
* Set default parameters when running license generator
* Release generator
* Use readJson instead of readNxJson as we want just the contents in the repo, not the fully resolved config
* Fix reading generator defaults + use generator-written formatting for release-please-config
* Add release generator to generators.json
* Fix no-publish release workflow
* Fix lockfile
* Add  to release-please-config.json
* Add canary release handling
  • Loading branch information
luxaritas authored Aug 25, 2022
1 parent 12d5ac7 commit 19939bd
Show file tree
Hide file tree
Showing 35 changed files with 17,936 additions and 6,782 deletions.
4 changes: 2 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ updates:
- 'type: dependencies'
- 'scope: repo'
commit-message:
prefix: chore(repo)
prefix: deps(repo)
- package-ecosystem: 'npm'
directory: '/'
schedule:
Expand All @@ -17,6 +17,6 @@ updates:
- 'type: dependencies'
- 'scope: repo'
commit-message:
prefix: chore(repo)
prefix: deps(repo)
# Security updates only
open-pull-requests-limit: 0
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Lint PR'
name: Lint PR

on:
pull_request_target:
Expand All @@ -16,6 +16,16 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
types:
feat
fix
perf
revert
deps
docs
refactor
test
chore
scopes: |
repo
bootstrap
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Release

on:
push:
branches:
- main

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
releases_created: ${{ steps.prep-release.outputs.releases_created }}
steps:
- name: Prep release
id: prep-release
uses: google-github-actions/release-please-action@v3
with:
command: manifest

update-lockfile:
name: Update release PR with lockfile updates
runs-on: ubuntu-latest
needs: release-please
if: needs.release-please.outputs.releases_created != 'true'
steps:
- uses: actions/checkout@v2
with:
ref: release-please--branches--main
fetch-depth: 2
- uses: actions/setup-node@v1
with:
node-version: 16
- name: Update package-lock.json
run: npm install --no-audit --no-fund --ignore-scripts --package-lock-only
- name: Merge changes with last commit
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit --amend --no-edit
git push -f
npm-publish:
needs: release-please
if: ${{ needs.release-please.outputs.releases_created }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: 'https://registry.npmjs.org'
- name: Use the node_modules cache if available
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-
- run: npm ci
- run: npm publish -ws --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

canary-release:
name: Release canary versions to NPM
runs-on: ubuntu-latest
needs: release-please
if: needs.release-please.outputs.releases_created != 'true'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v1
with:
node-version: 16
- name: Use the node_modules cache if available
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.versions.outputs.node_version }}-
- run: npm ci
- run: npx lerna publish --yes
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
9 changes: 9 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": true,
"useWorkspaces": true,
"version": "independent",
"canary": true,
"preid": "dev",
"preDistTag": "canary"
}
3 changes: 3 additions & 0 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"@eternagame/nx-plugin:license": {
"license": "BSD3",
"copyrightHolder": "Eterna Commons"
},
"@eternagame/nx-plugin:release": {
"publishing": "default-publish"
}
}
}
Loading

0 comments on commit 19939bd

Please sign in to comment.