mirror of https://github.com/nocodb/nocodb
Wing-Kam Wong
2 years ago
3 changed files with 269 additions and 0 deletions
@ -0,0 +1,143 @@
|
||||
name: "Release : Docker (v2)" |
||||
|
||||
on: |
||||
# Triggered manually |
||||
workflow_dispatch: |
||||
inputs: |
||||
tag: |
||||
description: "Docker image tag" |
||||
required: true |
||||
targetEnv: |
||||
description: "Target Environment" |
||||
required: true |
||||
type: choice |
||||
options: |
||||
- DEV |
||||
- PROD |
||||
# Triggered by release-nocodb.yml / release-nightly-dev.yml / release-pr.yml |
||||
workflow_call: |
||||
inputs: |
||||
tag: |
||||
description: "Docker image tag" |
||||
required: true |
||||
type: string |
||||
targetEnv: |
||||
description: "Target Environment" |
||||
required: true |
||||
type: string |
||||
isDaily: |
||||
description: "Is it triggered by daily schedule" |
||||
required: false |
||||
type: string |
||||
currentVersion: |
||||
description: "The current NocoDB version" |
||||
required: false |
||||
type: string |
||||
secrets: |
||||
DOCKERHUB_USERNAME: |
||||
required: true |
||||
DOCKERHUB_TOKEN: |
||||
required: true |
||||
|
||||
jobs: |
||||
buildx: |
||||
runs-on: ubuntu-latest |
||||
env: |
||||
working-directory: ./packages/nocodb |
||||
steps: |
||||
- name: Get Docker Repository |
||||
id: get-docker-repository |
||||
run: | |
||||
DOCKER_REPOSITORY=nocodb |
||||
DOCKER_BUILD_TAG=${{ github.event.inputs.tag || inputs.tag }} |
||||
if [[ ${{ github.event.inputs.targetEnv || inputs.targetEnv }} == 'DEV' ]]; then |
||||
if [[ ${{ github.event.inputs.currentVersion || inputs.currentVersion || 'N/A' }} != 'N/A' ]]; then |
||||
DOCKER_BUILD_TAG=${{ github.event.inputs.currentVersion || inputs.currentVersion }}-${{ github.event.inputs.tag || inputs.tag }} |
||||
fi |
||||
if [[ ${{ inputs.isDaily || 'N' }} == 'Y' ]]; then |
||||
DOCKER_REPOSITORY=${DOCKER_REPOSITORY}-daily |
||||
else |
||||
DOCKER_REPOSITORY=${DOCKER_REPOSITORY}-timely |
||||
fi |
||||
fi |
||||
echo "::set-output name=DOCKER_REPOSITORY::${DOCKER_REPOSITORY}" |
||||
echo "::set-output name=DOCKER_BUILD_TAG::${DOCKER_BUILD_TAG}" |
||||
echo ${DOCKER_REPOSITORY} |
||||
echo ${DOCKER_BUILD_TAG} |
||||
|
||||
- name: Checkout |
||||
uses: actions/checkout@v2 |
||||
with: |
||||
fetch-depth: 0 |
||||
ref: ${{ github.ref }} |
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }} |
||||
uses: actions/setup-node@v2 |
||||
with: |
||||
node-version: 16.15.0 |
||||
|
||||
- name: upgrade packages for nightly build or pr build |
||||
if: ${{ github.event.inputs.targetEnv == 'DEV' || inputs.targetEnv == 'DEV' }} |
||||
run: | |
||||
targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} node scripts/bumpNocodbSdkVersion.js |
||||
cd packages/nocodb-sdk |
||||
npm install && npm run build |
||||
cd ../.. |
||||
targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNocodbSdk.js |
||||
cd packages/nc-gui |
||||
npm install |
||||
targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} targetVersion=${{ github.event.inputs.tag || inputs.tag }} npm run build:copy |
||||
cd ../.. |
||||
targetEnv=${{ github.event.inputs.targetEnv || inputs.targetEnv }} node scripts/upgradeNcGui.js |
||||
|
||||
- uses: bahmutov/npm-install@v1 |
||||
with: |
||||
working-directory: ${{ env.working-directory }} |
||||
|
||||
- name: Build nocodb and docker files |
||||
run: | |
||||
npm run build |
||||
npm run docker:build |
||||
working-directory: ${{ env.working-directory }} |
||||
|
||||
- name: Set up QEMU |
||||
uses: docker/setup-qemu-action@v1 |
||||
|
||||
- name: Set up Docker Buildx |
||||
id: buildx |
||||
uses: docker/setup-buildx-action@v1 |
||||
|
||||
- name: Cache Docker layers |
||||
uses: actions/cache@v2 |
||||
with: |
||||
path: /tmp/.buildx-cache |
||||
key: ${{ runner.os }}-buildx-${{ github.sha }} |
||||
restore-keys: | |
||||
${{ runner.os }}-buildx- |
||||
|
||||
- name: Login to DockerHub |
||||
uses: docker/login-action@v1 |
||||
with: |
||||
username: ${{ secrets.DOCKERHUB_USERNAME }} |
||||
password: ${{ secrets.DOCKERHUB_TOKEN }} |
||||
|
||||
- name: Build and push |
||||
uses: docker/build-push-action@v2 |
||||
with: |
||||
context: ${{ env.working-directory }} |
||||
build-args: NC_VERSION=${{ steps.get-docker-repository.outputs.DOCKER_BUILD_TAG }} |
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7 |
||||
cache-from: type=local,src=/tmp/.buildx-cache |
||||
cache-to: type=local,dest=/tmp/.buildx-cache-new |
||||
push: true |
||||
tags: | |
||||
nocodb/${{ steps.get-docker-repository.outputs.DOCKER_REPOSITORY }}:${{ steps.get-docker-repository.outputs.DOCKER_BUILD_TAG }} |
||||
nocodb/${{ steps.get-docker-repository.outputs.DOCKER_REPOSITORY }}:latest |
||||
|
||||
# Temp fix |
||||
# https://github.com/docker/build-push-action/issues/252 |
||||
# https://github.com/moby/buildkit/issues/1896 |
||||
- name: Move cache |
||||
run: | |
||||
rm -rf /tmp/.buildx-cache |
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
@ -0,0 +1,126 @@
|
||||
name: 'PR Release (v2)' |
||||
|
||||
on: |
||||
pull_request: |
||||
# opened: pull request is created |
||||
# reopened: closed pull request is reopened |
||||
# synchronize: commit(s) pushed to the pull request |
||||
# ready_for_review: non PR release |
||||
types: [opened, reopened, synchronize, ready_for_review] |
||||
paths: |
||||
- "packages/nocodb-sdk/**" |
||||
- "packages/nc-gui-v2/**" |
||||
- "packages/nc-plugin/**" |
||||
- "packages/nocodb/**" |
||||
jobs: |
||||
# enrich tag for pr release |
||||
set-tag: |
||||
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false && github.base_ref == 'develop' }} |
||||
runs-on: 'ubuntu-latest' |
||||
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: |
||||
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false && github.base_ref == 'develop' }} |
||||
needs: [set-tag] |
||||
uses: ./.github/workflows/release-npm-v2.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: |
||||
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false && github.base_ref == 'develop' }} |
||||
needs: [release-npm, set-tag] |
||||
uses: ./.github/workflows/release-docker-v2.yml |
||||
with: |
||||
currentVersion: ${{ needs.set-tag.outputs.current_version }} |
||||
tag: ${{ needs.set-tag.outputs.target_tag }} |
||||
targetEnv: 'DEV' |
||||
isDaily: 'N' |
||||
secrets: |
||||
DOCKERHUB_USERNAME: "${{ secrets.DOCKERHUB_USERNAME }}" |
||||
DOCKERHUB_TOKEN: "${{ secrets.DOCKERHUB_TOKEN }}" |
||||
|
||||
# Build executables and publish to GitHub |
||||
release-executables: |
||||
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false && github.base_ref == 'develop' }} |
||||
needs: [set-tag, release-npm] |
||||
uses: ./.github/workflows/release-timely-executables.yml |
||||
with: |
||||
tag: ${{ needs.set-tag.outputs.current_version }}-${{ needs.set-tag.outputs.target_tag }} |
||||
secrets: |
||||
NC_GITHUB_TOKEN: "${{ secrets.NC_GITHUB_TOKEN }}" |
||||
|
||||
# Add a comment for PR docker build |
||||
leave-comment: |
||||
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false && github.base_ref == 'develop' }} |
||||
runs-on: 'ubuntu-latest' |
||||
needs: [release-docker, set-tag] |
||||
steps: |
||||
- uses: peter-evans/commit-comment@v2 |
||||
with: |
||||
body: | |
||||
The PR changes have been deployed. Please run the following command to verify: |
||||
``` |
||||
docker run -d -p 8888:8080 nocodb/nocodb-timely:${{ needs.set-tag.outputs.current_version }}-${{ needs.set-tag.outputs.target_tag }} |
||||
``` |
||||
|
||||
# Add a comment for PR executable build |
||||
leave-executable-comment: |
||||
if: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.draft == false && github.base_ref == 'develop' }} |
||||
runs-on: 'ubuntu-latest' |
||||
needs: [release-executables, set-tag] |
||||
steps: |
||||
- uses: peter-evans/commit-comment@v2 |
||||
with: |
||||
body: | |
||||
### Run Executables |
||||
|
||||
#### MacOS |
||||
|
||||
```bash |
||||
mkdir -p ./${{ needs.set-tag.outputs.current_version }}/${{ needs.set-tag.outputs.target_tag }} && cd "$_" \ |
||||
&& curl http://dl.nocodb.com/${{ needs.set-tag.outputs.current_version }}-${{ needs.set-tag.outputs.target_tag }}/Noco-macos-arm64 -o noco -L \ |
||||
&& chmod +x noco \ |
||||
&& ./noco |
||||
``` |
||||
#### Linux |
||||
|
||||
```bash |
||||
mkdir -p ./${{ needs.set-tag.outputs.current_version }}/${{ needs.set-tag.outputs.target_tag }} && cd "$_" \ |
||||
&& curl http://dl.nocodb.com/${{ needs.set-tag.outputs.current_version }}-${{ needs.set-tag.outputs.target_tag }}/Noco-linux-x64 -o noco -L \ |
||||
&& chmod +x noco \ |
||||
&& ./noco |
||||
``` |
||||
#### Windows |
||||
|
||||
```bash |
||||
iwp http://dl.nocodb.com/${{ needs.set-tag.outputs.current_version }}-${{ needs.set-tag.outputs.target_tag }}/Noco-win-arm64.exe |
||||
.\Noco-win-arm64.exe |
||||
``` |
||||
|
||||
For executables visit [here](https://github.com/nocodb/nocodb-timely/releases/tag/${{ needs.set-tag.outputs.current_version }}-${{ needs.set-tag.outputs.target_tag }}) |
Loading…
Reference in new issue