-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: release and publishing automation (#786)
* Update CONTRIBUTING.md Co-authored-by: Kyle Peacock <[email protected]> * run npm audit before publishing
- Loading branch information
Marcin Nowak-Liebiediew
authored
Nov 1, 2023
1 parent
6d45a41
commit bb665ce
Showing
17 changed files
with
3,719 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Prepare Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
semverBump: | ||
description: 'Specify next SemVer version (either of: "patch", "minor", "major", "prepatch", "preminor", "premajor", or custom SemVer compatible version (e.g. "0.32.1-beta.1", or "1.0.0"))' | ||
type: string | ||
required: true | ||
default: 'patch' | ||
|
||
jobs: | ||
create-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Cache node modules | ||
id: cache-npm | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | ||
name: List the state of node modules | ||
continue-on-error: true | ||
run: npm list | ||
- name: Install node dependencies | ||
run: npm ci | ||
- name: Set up git config | ||
run: | | ||
git config author.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" | ||
git config author.name "${{ github.event.sender.login }}" | ||
git config committer.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
git config committer.name "GitHub Actions Bot" | ||
git config user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" | ||
git config user.name "${{ github.event.sender.login }}" | ||
- name: Create release Pull request & GitHub Release | ||
env: | ||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | ||
run: npm run release ${{ inputs.semverBump }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Publish and Release | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
|
||
jobs: | ||
publish: | ||
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Extract version from branch name | ||
run: | | ||
BRANCH="${{ github.event.pull_request.head.ref }}" | ||
VERSION="${BRANCH#release/}" | ||
echo "BRANCH=$BRANCH" >> $GITHUB_ENV | ||
echo "VERSION_TAG=v$VERSION" >> $GITHUB_ENV | ||
- name: Mark as Latest Release in GitHub Releases | ||
env: | ||
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | ||
run: | | ||
gh release edit "${{ env.VERSION_TAG }}" --draft=false --prerelease=false --latest=true | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Cache node modules | ||
id: cache-npm | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-node-modules | ||
with: | ||
# npm cache files are stored in `~/.npm` on Linux/macOS | ||
path: ~/.npm | ||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
${{ runner.os }}-build-${{ env.cache-name }}- | ||
${{ runner.os }}-build- | ||
${{ runner.os }}- | ||
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | ||
name: List the state of node modules | ||
continue-on-error: true | ||
run: npm list | ||
- run: npm ci | ||
- run: npm audit | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
# publish docs | ||
- name: Install dfx | ||
run: dfinity/setup-dfx@main | ||
- name: Regenerate project's documentation | ||
run: npm run make:docs | ||
- name: Add new identity to dfx | ||
run: | | ||
echo ${{ secrets.DFX_IDENTITY_PEM }} > identity.pem | ||
dfx identity import docs-deployer identity.pem | ||
dfx identity use docs-deployer | ||
- name: Deploy docs | ||
run: dfx deploy --network ic | ||
|
||
- name: Delete release branch | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: git push origin --delete ${{ env.BRANCH }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.