Skip to content

Commit

Permalink
Merge pull request #124 from privacy-scaling-explorations/ci/update
Browse files Browse the repository at this point in the history
ci: add npm publish pipeline
  • Loading branch information
baumstern authored Jul 26, 2023
2 parents 9b6fd60 + af56cde commit e2cb254
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 64 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ concurrency:
cancel-in-progress: true

jobs:

deploy-staging:
uses: ./.github/workflows/firebase-deploy.yaml
secrets: inherit
with:
environment: staging-for-deploy
environment: staging
branch: ${{ github.ref }}
firebase_project: ${{ vars.FIREBASE_PROJECT_STAGING }}
56 changes: 56 additions & 0 deletions .github/workflows/publish-dev-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Publish @devtion

on:
push:
branches:
- dev

jobs:
npm-publish:
runs-on: ubuntu-22.04
environment: dev

steps:
- uses: actions/checkout@v3

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
cache: yarn

- name: Initialize Project
run: |
yarn install --immutable
yarn build
env:
NODE_OPTIONS: "--max_old_space_size=4096"

- name: Install lerna
run: |
npm install -g [email protected]
- name: Modify package name
run: |
sed -i -e 's/"name": "@p0tion\/phase2cli"/"name": "@devtion\/devcli"/g' ./packages/phase2cli/package.json
sed -i -e 's/"name": "@p0tion\/backend"/"name": "@devtion\/backend"/g' ./packages/backend/package.json
sed -i -e 's/"name": "@p0tion\/actions"/"name": "@devtion\/actions"/g' ./packages/actions/package.json
- name: Publish packages
run: |
# Prevent `git commit error` when running `lerna version`
# It will not pushed to GitHub. It is ephemeral
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git add .
git commit -m "chore: publish packages" --no-verify
echo "${{ vars.CLI_ENV_FILE }}" > ./packages/phase2cli/dist/.env
lerna version 0.0.0-$(git rev-parse --short HEAD) --no-push --ignore-scripts --message "chore(release): publish packages" --yes
lerna publish from-git --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/publish-on-tag-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Publish to NPM

on:
push:
tags: ["*"]

jobs:
npm-publish:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
cache: yarn

- name: Initialize Project
run: |
yarn install --immutable
yarn build
env:
NODE_OPTIONS: "--max_old_space_size=4096"

- name: Install lerna
run: |
npm install -g [email protected]
- name: Publish packages
run: |
echo "${{ vars.CLI_ENV_FILE }}" > ./packages/phase2cli/dist/.env
lerna publish from-git --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/publish-production-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish @p0tion

on:
push:
branches:
- main

jobs:
npm-publish:
runs-on: ubuntu-22.04
environment: production

steps:
- uses: actions/checkout@v3

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
cache: yarn

- name: Initialize Project
run: |
yarn install --immutable
yarn build
env:
NODE_OPTIONS: "--max_old_space_size=4096"

- name: Install lerna
run: |
npm install -g [email protected]
- name: Publish packages
run: |
echo "${{ vars.CLI_ENV_FILE }}" > ./packages/phase2cli/dist/.env
lerna version 0.0.0-$(git rev-parse --short HEAD) --no-push --ignore-scripts --message "chore(release): publish packages" --yes
lerna publish from-git --dist-tag ci --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/publish-staging-packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish @stagtion

on:
push:
branches:
- staging

jobs:
npm-publish:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
cache: yarn

- name: Initialize Project
run: |
yarn install --immutable
yarn build
env:
NODE_OPTIONS: "--max_old_space_size=4096"

- name: Install lerna
run: |
npm install -g [email protected]
- name: Modify package name
run: |
sed -i -e 's/"name": "@p0tion\/phase2cli"/"name": "@stagtion\/stagcli"/g' ./packages/phase2cli/package.json
sed -i -e 's/"name": "@p0tion\/backend"/"name": "@stagtion\/backend"/g' ./packages/backend/package.json
sed -i -e 's/"name": "@p0tion\/actions"/"name": "@stagtion\/actions"/g' ./packages/actions/package.json
- name: Publish packages
run: |
# Prevent `git commit error` when running `lerna version`
# It will not pushed to GitHub. It is ephemeral
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
git add .
git commit -m "chore: publish packages" --no-verify
echo "${{ vars.CLI_ENV_FILE }}" > ./packages/phase2cli/dist/.env
lerna version 0.0.0-$(git rev-parse --short HEAD) --no-push --ignore-scripts --message "chore(release): publish packages" --yes
lerna publish from-git --yes
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48 changes: 0 additions & 48 deletions .github/workflows/publish-to-npm.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test-firebase-emulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test Firebase Emulator
on:
pull_request:
push:
branches: [main, dev]
branches: [main, staging, dev]

jobs:
start-runner:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ concurrency:
cancel-in-progress: true

jobs:

test-staging:
uses: ./.github/workflows/firebase-test.yaml
secrets: inherit
with:
environment: staging-for-deploy
environment: staging
github_ref: ${{ github.ref }}
firebase_project: ${{ vars.FIREBASE_PROJECT_STAGING }}
18 changes: 8 additions & 10 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git clone https://github.com/privacy-scaling-explorations/p0tion.git
3. Install required dependencies:

```
yarn install
yarn install --immutable
```

4. Install required global dependencies:
Expand All @@ -26,20 +26,18 @@ npm install -g conventional-changelog-conventionalcommits
5. Run `lerna version` to update CHANGELOG and version numbers of sub-packages:

```
npx lerna version --no-push --no-git-tag-version --conventional-commits 1.2.3
npx lerna version --no-push --no-git-tag-version --conventional-commits 1.2.3 --message "chore(release): publish 1.2.3"
```

6. Commit changes:
6. Push changes and create a pull request

```
git commit --message "chore(release): publish 1.2.3"
```

7. Push changes and create a pull request
7. Merge pull request into main branch

After the pull request has been merged:
8. Retrieve merged commit from main branch:

8. Retrieve merged commit
```
git pull origin main
```

9. Add a tag:

Expand Down
1 change: 0 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"packages/*"
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "1.0.5",
"changelogPreset": {
"name": "conventionalcommits",
Expand Down

0 comments on commit e2cb254

Please sign in to comment.