Browse Source

wip: pr release

pull/1892/head
Wing-Kam Wong 3 years ago
parent
commit
d5117d3c8b
  1. 9
      .github/workflows/release-docker.yml
  2. 3
      .github/workflows/release-npm.yml
  3. 90
      .github/workflows/release-pr.yml
  4. 2
      scripts/bumpNocodbSdkVersion.js
  5. 2
      scripts/upgradeNcGui.js
  6. 4
      scripts/upgradeNocodbSdk.js

9
.github/workflows/release-docker.yml

@ -49,7 +49,10 @@ jobs:
run: | run: |
DOCKER_REPOSITORY=nocodb DOCKER_REPOSITORY=nocodb
REF_BRANCH=master REF_BRANCH=master
if [[ ${{ github.event.inputs.targetEnv || inputs.targetEnv }} == 'DEV' ]]; then if [[ ${{ github.event.inputs.targetEnv || inputs.targetEnv }} == 'PR' ]]; then
REF_BRANCH="refs/pull/${{ github.event.number }}/merge"
DOCKER_REPOSITORY=${DOCKER_REPOSITORY}-timely
elif [[ ${{ github.event.inputs.targetEnv || inputs.targetEnv }} == 'DEV' ]]; then
REF_BRANCH=develop REF_BRANCH=develop
if [[ ${{ inputs.isDaily || 'N' }} == 'Y' ]]; then if [[ ${{ inputs.isDaily || 'N' }} == 'Y' ]]; then
DOCKER_REPOSITORY=${DOCKER_REPOSITORY}-daily DOCKER_REPOSITORY=${DOCKER_REPOSITORY}-daily
@ -73,8 +76,8 @@ jobs:
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: upgrade packages for nightly build - name: upgrade packages for nightly build or pr build
if: ${{ github.event.inputs.targetEnv == 'DEV' || inputs.targetEnv == 'DEV' }} if: ${{ github.event.inputs.targetEnv == 'DEV' || inputs.targetEnv == 'DEV' || github.event.inputs.targetEnv == 'PR' || inputs.targetEnv == 'PR' }}
run: | run: |
targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNocodbSdkVersion.js targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNocodbSdkVersion.js
cd packages/nocodb-sdk cd packages/nocodb-sdk

3
.github/workflows/release-npm.yml

@ -14,7 +14,7 @@ on:
options: options:
- DEV - DEV
- PROD - PROD
# Triggered by release-nocodb.yml / release-nightly-dev.yml # Triggered by release-nocodb.yml / release-nightly-dev.yml / release-pr.yml
workflow_call: workflow_call:
inputs: inputs:
tag: tag:
@ -83,6 +83,7 @@ jobs:
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: automerge - name: automerge
if: ${{ github.event.inputs.targetEnv == 'PROD' || inputs.targetEnv == 'PROD' }}
uses: "pascalgn/automerge-action@v0.14.3" uses: "pascalgn/automerge-action@v0.14.3"
env: env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

90
.github/workflows/release-pr.yml

@ -0,0 +1,90 @@
name: 'PR Release'
on:
pull_request:
types: [
opened, # pull request is created
reopened, # closed pull request is reopened
synchronize # commit(s) pushed to the pull request
]
paths:
- "packages/nocodb-sdk/**"
- "packages/nc-gui/**"
- "packages/nc-plugin/**"
- "packages/nocodb/**"
jobs:
# Validate Branch
validate-branch:
runs-on: ubuntu-latest
steps:
- run: |
if [[ ${{ github.base_ref }} != 'develop' ]]; then
echo "PR Release only runs on develop as a base branch"
exit 1
fi
# enrich tag for pr release
set-tag:
runs-on: 'ubuntu-latest'
needs: [validate-branch]
steps:
- name: set-tag
id: tag-step
run: |
# Get current date
CURRENT_DATE=$(date +"%Y%m%d")
CURRENT_TIME=$(date +"%H%M")
# Get current PR number
PR_NUMBER=${{github.event.number}}
# Get current version
CURRENT_VERSION=$(basename $(curl -fs -o/dev/null -w %{redirect_url} https://github.com/nocodb/nocodb/releases/latest))
# Construct tag name
TAG_NAME=pr-${PR_NUMBER}-${CURRENT_DATE}-${CURRENT_TIME}
echo "::set-output name=TARGET_TAG::${TAG_NAME}"
echo "::set-output name=CURRENT_VERSION::${CURRENT_VERSION}"
- name: verify-tag
run: |
echo ${{ steps.tag-step.outputs.TARGET_TAG }}
echo ${{ steps.tag-step.outputs.CURRENT_VERSION }}
outputs:
target_tag: ${{ steps.tag-step.outputs.TARGET_TAG }}
current_version: ${{ steps.tag-step.outputs.CURRENT_VERSION }}
# Build, install, publish frontend and backend to npm
release-npm:
needs: [set-tag]
uses: ./.github/workflows/release-npm.yml
with:
tag: ${{ needs.set-tag.outputs.target_tag }}
targetEnv: 'DEV'
secrets:
NPM_TOKEN: "${{ secrets.NPM_TOKEN }}"
# Build docker image and push to docker hub
release-docker:
needs: [release-npm, set-tag]
uses: ./.github/workflows/release-docker.yml
with:
tag: ${{ needs.set-tag.outputs.target_tag }}
targetEnv: 'PR'
isDaily: 'N'
secrets:
DOCKERHUB_USERNAME: "${{ secrets.DOCKERHUB_USERNAME }}"
DOCKERHUB_TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}"
leave-comment:
needs: [release-docker, set-tag]
uses: peter-evans/commit-comment@v2
with:
body: |
The PR changes have been deployed. Pleae run the following command to verify:
```
docker run -d -p 8888:8080 nocodb-timely:${{ needs.set-tag.outputs.current_version }}-${{ needs.set-tag.outputs.target_tag }}
```
# if-merged:
# if: github.event.pull_request.merged == true
# runs-on: ubuntu-latest
# steps:
# - run: |
# echo The PR was merged

2
scripts/bumpNocodbSdkVersion.js

@ -10,6 +10,8 @@ const version = packageJson.version
if (process.env.targetEnv === 'DEV') { if (process.env.targetEnv === 'DEV') {
// nightly build // nightly build
// e.g. 0.84.2-20220220-1250 // e.g. 0.84.2-20220220-1250
// pr build
// e.g. 0.84.2-pr-1234-20220220-1250
packageJson.version = `${packageJson.version}-${process.env.targetVersion}` packageJson.version = `${packageJson.version}-${process.env.targetVersion}`
packageJson.name += '-daily' packageJson.name += '-daily'
} else { } else {

2
scripts/upgradeNcGui.js

@ -33,7 +33,7 @@ const bumbVersionAndSave = () => {
} }
if (process.env.targetEnv === 'DEV') { if (process.env.targetEnv === 'DEV') {
// replace nc-lib-gui by nc-lib-gui-daily if it is nightly build // replace nc-lib-gui by nc-lib-gui-daily if it is nightly build / pr release
const filePaths = [ const filePaths = [
path.join(__dirname, '..', 'packages', 'nocodb', 'Dockerfile'), path.join(__dirname, '..', 'packages', 'nocodb', 'Dockerfile'),
path.join(__dirname, '..', 'packages', 'nocodb', 'litestream', 'Dockerfile'), path.join(__dirname, '..', 'packages', 'nocodb', 'litestream', 'Dockerfile'),

4
scripts/upgradeNocodbSdk.js

@ -1,7 +1,5 @@
const fs = require('fs') const fs = require('fs')
const path = require('path'); const path = require('path');
const { mainModule } = require('process');
const execSync = require('child_process').execSync; const execSync = require('child_process').execSync;
// extract latest version from package.json // extract latest version from package.json
@ -68,7 +66,7 @@ const searchAndReplace = (target) => {
} }
if (process.env.targetEnv === 'DEV') { if (process.env.targetEnv === 'DEV') {
// replace nocodb-sdk by nocodb-sdk-daily if it is nightly build // replace nocodb-sdk by nocodb-sdk-daily if it is nightly build / pr build
searchAndReplace('nocodb-sdk') searchAndReplace('nocodb-sdk')
.then(() => { .then(() => {
bumbVersionAndSave() bumbVersionAndSave()

Loading…
Cancel
Save