diff --git a/.github/workflows/deploy-staging.yaml b/.github/workflows/deploy-staging.yaml index 7fa8eb5d..490fa073 100644 --- a/.github/workflows/deploy-staging.yaml +++ b/.github/workflows/deploy-staging.yaml @@ -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 }} diff --git a/.github/workflows/publish-dev-packages.yaml b/.github/workflows/publish-dev-packages.yaml new file mode 100644 index 00000000..ddaa91db --- /dev/null +++ b/.github/workflows/publish-dev-packages.yaml @@ -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 lerna@7.1.4 + + - 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 "you@example.com" + 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 }} diff --git a/.github/workflows/publish-on-tag-push.yaml b/.github/workflows/publish-on-tag-push.yaml new file mode 100644 index 00000000..998a9761 --- /dev/null +++ b/.github/workflows/publish-on-tag-push.yaml @@ -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 lerna@7.1.4 + + - 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 }} diff --git a/.github/workflows/publish-production-packages.yaml b/.github/workflows/publish-production-packages.yaml new file mode 100644 index 00000000..405ee484 --- /dev/null +++ b/.github/workflows/publish-production-packages.yaml @@ -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 lerna@7.1.4 + + - 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 }} diff --git a/.github/workflows/publish-staging-packages.yaml b/.github/workflows/publish-staging-packages.yaml new file mode 100644 index 00000000..38e052f0 --- /dev/null +++ b/.github/workflows/publish-staging-packages.yaml @@ -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 lerna@7.1.4 + + - 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 "you@example.com" + 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 }} diff --git a/.github/workflows/publish-to-npm.yaml b/.github/workflows/publish-to-npm.yaml deleted file mode 100644 index 941b6fdd..00000000 --- a/.github/workflows/publish-to-npm.yaml +++ /dev/null @@ -1,48 +0,0 @@ -name: Publish to NPM - -on: - workflow_call: - inputs: - github_ref: - description: 'The branch or tag ref that triggered the workflow' - required: true - type: string - -jobs: - npm-publish: - runs-on: ubuntu-22.04 - - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ inputs.github_ref }} - - - 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 add --dev lerna - yarn build - env: - NODE_OPTIONS: "--max_old_space_size=4096" - - - name: Publish Project - run: | - # Prevent `git commit error` when running `lerna version` - # It will not pushed to GitHub. It is ephemeral - git config --global user.email "you@example.com" - git config --global user.name "Your Name" - - # Workaround to not include changes by adding lerna - git reset --hard HEAD - - lerna version 0.0.0-${{ inputs.github_ref }}.$(git rev-parse --short HEAD) --no-push --yes - lerna publish from-git --dist-tag ci --yes - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test-firebase-emulator.yaml b/.github/workflows/test-firebase-emulator.yaml index 59523d6c..2d34e409 100644 --- a/.github/workflows/test-firebase-emulator.yaml +++ b/.github/workflows/test-firebase-emulator.yaml @@ -3,7 +3,7 @@ name: Test Firebase Emulator on: pull_request: push: - branches: [main, dev] + branches: [main, staging, dev] jobs: start-runner: diff --git a/.github/workflows/test-staging.yaml b/.github/workflows/test-staging.yaml index ed48bc02..2cfd71dd 100644 --- a/.github/workflows/test-staging.yaml +++ b/.github/workflows/test-staging.yaml @@ -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 }} diff --git a/RELEASE.md b/RELEASE.md index c1ce9c78..2a8d43b9 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -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: @@ -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: diff --git a/lerna.json b/lerna.json index 86e8e592..52cfe186 100644 --- a/lerna.json +++ b/lerna.json @@ -3,7 +3,6 @@ "packages/*" ], "npmClient": "yarn", - "useWorkspaces": true, "version": "1.0.5", "changelogPreset": { "name": "conventionalcommits",