diff --git a/.github/actions/build-push-action/action.yml b/.github/actions/build-push-action/action.yml new file mode 100644 index 00000000000..acf06982d31 --- /dev/null +++ b/.github/actions/build-push-action/action.yml @@ -0,0 +1,126 @@ +name: "Build and Push Docker Image" +description: "Reusable action for building and pushing Docker images" +inputs: + docker-username: + description: "The Dockerhub username" + required: true + docker-token: + description: "The Dockerhub Token" + required: true + + # Docker Image Options + docker-image-owner: + description: "The owner of the Docker image" + required: true + docker-image-name: + description: "The name of the Docker image" + required: true + build-context: + description: "The build context" + required: true + default: "." + dockerfile-path: + description: "The path to the Dockerfile" + required: true + build-args: + description: "The build arguments" + required: false + default: "" + + # Buildx Options + buildx-driver: + description: "Buildx driver" + required: true + default: "docker-container" + buildx-version: + description: "Buildx version" + required: true + default: "latest" + buildx-platforms: + description: "Buildx platforms" + required: true + default: "linux/amd64" + buildx-endpoint: + description: "Buildx endpoint" + required: true + default: "default" + + # Release Build Options + build-release: + description: "Flag to publish release" + required: false + default: "false" + build-prerelease: + description: "Flag to publish prerelease" + required: false + default: "false" + release-version: + description: "The release version" + required: false + default: "latest" + +runs: + using: "composite" + steps: + - name: Set Docker Tag + shell: bash + env: + IMG_OWNER: ${{ inputs.docker-image-owner }} + IMG_NAME: ${{ inputs.docker-image-name }} + BUILD_RELEASE: ${{ inputs.build-release }} + IS_PRERELEASE: ${{ inputs.build-prerelease }} + REL_VERSION: ${{ inputs.release-version }} + run: | + FLAT_BRANCH_VERSION=$(echo "${{ github.ref_name }}" | sed 's/[^a-zA-Z0-9.-]//g') + + if [ "${{ env.BUILD_RELEASE }}" == "true" ]; then + semver_regex="^v([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)?$" + if [[ ! ${{ env.REL_VERSION }} =~ $semver_regex ]]; then + echo "Invalid Release Version Format : ${{ env.REL_VERSION }}" + echo "Please provide a valid SemVer version" + echo "e.g. v1.2.3 or v1.2.3-alpha-1" + echo "Exiting the build process" + exit 1 # Exit with status 1 to fail the step + fi + + TAG=${{ env.IMG_OWNER }}/${{ env.IMG_NAME }}:${{ env.REL_VERSION }} + + if [ "${{ env.IS_PRERELEASE }}" != "true" ]; then + TAG=${TAG},${{ env.IMG_OWNER }}/${{ env.IMG_NAME }}:stable + fi + elif [ "${{ env.TARGET_BRANCH }}" == "master" ]; then + TAG=${{ env.IMG_OWNER }}/${{ env.IMG_NAME }}:latest + else + TAG=${{ env.IMG_OWNER }}/${{ env.IMG_NAME }}:${FLAT_BRANCH_VERSION} + fi + + echo "DOCKER_TAGS=${TAG}" >> $GITHUB_ENV + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ inputs.docker-username }} + password: ${{ inputs.docker-token}} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: ${{ inputs.buildx-driver }} + version: ${{ inputs.buildx-version }} + endpoint: ${{ inputs.buildx-endpoint }} + + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Build and Push Docker Image + uses: docker/build-push-action@v5.1.0 + with: + context: ${{ inputs.build-context }} + file: ${{ inputs.dockerfile-path }} + platforms: ${{ inputs.buildx-platforms }} + tags: ${{ env.DOCKER_TAGS }} + push: true + build-args: ${{ inputs.build-args }} + env: + DOCKER_BUILDKIT: 1 + DOCKER_USERNAME: ${{ inputs.docker-username }} + DOCKER_PASSWORD: ${{ inputs.docker-token }} \ No newline at end of file diff --git a/.github/workflows/build-branch.yml b/.github/workflows/build-branch.yml index d3e501a442a..d0798fda7ee 100644 --- a/.github/workflows/build-branch.yml +++ b/.github/workflows/build-branch.yml @@ -1,29 +1,45 @@ -name: Branch Build +name: Branch Build CE on: workflow_dispatch: inputs: + build_type: + description: "Type of build to run" + required: true + type: choice + default: "Build" + options: + - "Build" + - "Release" + releaseVersion: + description: "Release Version" + type: string + default: v0.0.0 + isPrerelease: + description: "Is Pre-release" + type: boolean + default: false + required: true arm64: description: "Build for ARM64 architecture" required: false default: false type: boolean - push: - branches: - - master - - preview - release: - types: [released, prereleased] + # push: + # branches: + # - master env: - TARGET_BRANCH: ${{ github.ref_name || github.event.release.target_commitish }} + TARGET_BRANCH: ${{ github.ref_name }} ARM64_BUILD: ${{ github.event.inputs.arm64 }} - IS_PRERELEASE: ${{ github.event.release.prerelease }} + BUILD_TYPE: ${{ github.event.inputs.build_type }} + RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }} + IS_PRERELEASE: ${{ github.event.inputs.isPrerelease }} jobs: branch_build_setup: name: Build Setup - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 outputs: gh_branch_name: ${{ steps.set_env_variables.outputs.TARGET_BRANCH }} gh_buildx_driver: ${{ steps.set_env_variables.outputs.BUILDX_DRIVER }} @@ -36,13 +52,24 @@ jobs: build_space: ${{ steps.changed_files.outputs.space_any_changed }} build_web: ${{ steps.changed_files.outputs.web_any_changed }} build_live: ${{ steps.changed_files.outputs.live_any_changed }} - flat_branch_name: ${{ steps.set_env_variables.outputs.FLAT_BRANCH_NAME }} + + dh_img_web: ${{ steps.set_env_variables.outputs.DH_IMG_WEB }} + dh_img_space: ${{ steps.set_env_variables.outputs.DH_IMG_SPACE }} + dh_img_admin: ${{ steps.set_env_variables.outputs.DH_IMG_ADMIN }} + dh_img_live: ${{ steps.set_env_variables.outputs.DH_IMG_LIVE }} + dh_img_backend: ${{ steps.set_env_variables.outputs.DH_IMG_BACKEND }} + dh_img_proxy: ${{ steps.set_env_variables.outputs.DH_IMG_PROXY }} + + build_type: ${{steps.set_env_variables.outputs.BUILD_TYPE}} + build_release: ${{ steps.set_env_variables.outputs.BUILD_RELEASE }} + build_prerelease: ${{ steps.set_env_variables.outputs.BUILD_PRERELEASE }} + release_version: ${{ steps.set_env_variables.outputs.RELEASE_VERSION }} steps: - id: set_env_variables name: Set Environment Variables run: | - if [ "${{ env.TARGET_BRANCH }}" == "master" ] || [ "${{ env.ARM64_BUILD }}" == "true" ] || ([ "${{ github.event_name }}" == "release" ] && [ "${{ env.IS_PRERELEASE }}" != "true" ]); then + if [ "${{ env.ARM64_BUILD }}" == "true" ] || ([ "${{ env.BUILD_TYPE }}" == "Release" ] && [ "${{ env.IS_PRERELEASE }}" != "true" ]); then echo "BUILDX_DRIVER=cloud" >> $GITHUB_OUTPUT echo "BUILDX_VERSION=lab:latest" >> $GITHUB_OUTPUT echo "BUILDX_PLATFORMS=linux/amd64,linux/arm64" >> $GITHUB_OUTPUT @@ -53,9 +80,43 @@ jobs: echo "BUILDX_PLATFORMS=linux/amd64" >> $GITHUB_OUTPUT echo "BUILDX_ENDPOINT=" >> $GITHUB_OUTPUT fi - echo "TARGET_BRANCH=${{ env.TARGET_BRANCH }}" >> $GITHUB_OUTPUT - flat_branch_name=$(echo ${{ env.TARGET_BRANCH }} | sed 's/[^a-zA-Z0-9\._]/-/g') - echo "FLAT_BRANCH_NAME=${flat_branch_name}" >> $GITHUB_OUTPUT + BR_NAME=$( echo "${{ env.TARGET_BRANCH }}" |sed 's/[^a-zA-Z0-9.-]//g') + echo "TARGET_BRANCH=$BR_NAME" >> $GITHUB_OUTPUT + + echo "DH_IMG_WEB=plane-frontend" >> $GITHUB_OUTPUT + echo "DH_IMG_SPACE=plane-space" >> $GITHUB_OUTPUT + echo "DH_IMG_ADMIN=plane-admin" >> $GITHUB_OUTPUT + echo "DH_IMG_LIVE=plane-live" >> $GITHUB_OUTPUT + echo "DH_IMG_BACKEND=plane-backend" >> $GITHUB_OUTPUT + echo "DH_IMG_PROXY=plane-proxy" >> $GITHUB_OUTPUT + + echo "BUILD_TYPE=${{env.BUILD_TYPE}}" >> $GITHUB_OUTPUT + BUILD_RELEASE=false + BUILD_PRERELEASE=false + RELVERSION="latest" + + if [ "${{ env.BUILD_TYPE }}" == "Release" ]; then + FLAT_RELEASE_VERSION=$(echo "${{ env.RELEASE_VERSION }}" | sed 's/[^a-zA-Z0-9.-]//g') + echo "FLAT_RELEASE_VERSION=${FLAT_RELEASE_VERSION}" >> $GITHUB_OUTPUT + + semver_regex="^v([0-9]+)\.([0-9]+)\.([0-9]+)(-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*)?$" + if [[ ! $FLAT_RELEASE_VERSION =~ $semver_regex ]]; then + echo "Invalid Release Version Format : $FLAT_RELEASE_VERSION" + echo "Please provide a valid SemVer version" + echo "e.g. v1.2.3 or v1.2.3-alpha-1" + echo "Exiting the build process" + exit 1 # Exit with status 1 to fail the step + fi + BUILD_RELEASE=true + RELVERSION=$FLAT_RELEASE_VERSION + + if [ "${{ env.IS_PRERELEASE }}" == "true" ]; then + BUILD_PRERELEASE=true + fi + fi + echo "BUILD_RELEASE=${BUILD_RELEASE}" >> $GITHUB_OUTPUT + echo "BUILD_PRERELEASE=${BUILD_PRERELEASE}" >> $GITHUB_OUTPUT + echo "RELEASE_VERSION=${RELVERSION}" >> $GITHUB_OUTPUT - id: checkout_files name: Checkout Files @@ -73,24 +134,24 @@ jobs: admin: - admin/** - packages/** - - 'package.json' - - 'yarn.lock' - - 'tsconfig.json' - - 'turbo.json' + - "package.json" + - "yarn.lock" + - "tsconfig.json" + - "turbo.json" space: - space/** - packages/** - - 'package.json' - - 'yarn.lock' - - 'tsconfig.json' - - 'turbo.json' + - "package.json" + - "yarn.lock" + - "tsconfig.json" + - "turbo.json" web: - web/** - packages/** - - 'package.json' - - 'yarn.lock' - - 'tsconfig.json' - - 'turbo.json' + - "package.json" + - "yarn.lock" + - "tsconfig.json" + - "turbo.json" live: - live/** - packages/** @@ -99,338 +160,224 @@ jobs: - 'tsconfig.json' - 'turbo.json' - branch_build_push_web: - if: ${{ needs.branch_build_setup.outputs.build_web == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} - name: Build-Push Web Docker Image + branch_build_push_admin: + if: ${{ needs.branch_build_setup.outputs.build_admin == 'true' || github.event_name == 'workflow_dispatch' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} + name: Build-Push Admin Docker Image runs-on: ubuntu-20.04 needs: [branch_build_setup] - env: - FRONTEND_TAG: makeplane/plane-frontend:${{ needs.branch_build_setup.outputs.flat_branch_name }} - TARGET_BRANCH: ${{ needs.branch_build_setup.outputs.gh_branch_name }} - BUILDX_DRIVER: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} - BUILDX_VERSION: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} - BUILDX_PLATFORMS: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} - BUILDX_ENDPOINT: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} steps: - - name: Set Frontend Docker Tag - run: | - if [ "${{ github.event_name }}" == "release" ]; then - TAG=makeplane/plane-frontend:${{ github.event.release.tag_name }} - if [ "${{ env.IS_PRERELEASE }}" != "true" ]; then - TAG=${TAG},makeplane/plane-frontend:stable - fi - elif [ "${{ env.TARGET_BRANCH }}" == "master" ]; then - TAG=makeplane/plane-frontend:latest - else - TAG=${{ env.FRONTEND_TAG }} - fi - echo "FRONTEND_TAG=${TAG}" >> $GITHUB_ENV - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: ${{ env.BUILDX_DRIVER }} - version: ${{ env.BUILDX_VERSION }} - endpoint: ${{ env.BUILDX_ENDPOINT }} - - - name: Check out the repo + - id: checkout_files + name: Checkout Files uses: actions/checkout@v4 - - - name: Build and Push Frontend to Docker Container Registry - uses: docker/build-push-action@v5.1.0 + - name: Admin Build and Push + uses: ./.github/actions/build-push-action with: - context: . - file: ./web/Dockerfile.web - platforms: ${{ env.BUILDX_PLATFORMS }} - tags: ${{ env.FRONTEND_TAG }} - push: true - env: - DOCKER_BUILDKIT: 1 - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + build-release: ${{ needs.branch_build_setup.outputs.build_release }} + build-prerelease: ${{ needs.branch_build_setup.outputs.build_prerelease }} + release-version: ${{ needs.branch_build_setup.outputs.release_version }} + docker-username: ${{ secrets.DOCKERHUB_USERNAME }} + docker-token: ${{ secrets.DOCKERHUB_TOKEN }} + docker-image-owner: makeplane + docker-image-name: ${{ needs.branch_build_setup.outputs.dh_img_admin }} + build-context: . + dockerfile-path: ./admin/Dockerfile.admin + buildx-driver: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} + buildx-version: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} + buildx-platforms: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} + buildx-endpoint: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} - branch_build_push_admin: - if: ${{ needs.branch_build_setup.outputs.build_admin== 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} - name: Build-Push Admin Docker Image + branch_build_push_web: + if: ${{ needs.branch_build_setup.outputs.build_web == 'true' || github.event_name == 'workflow_dispatch' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} + name: Build-Push Web Docker Image runs-on: ubuntu-20.04 needs: [branch_build_setup] - env: - ADMIN_TAG: makeplane/plane-admin:${{ needs.branch_build_setup.outputs.flat_branch_name }} - TARGET_BRANCH: ${{ needs.branch_build_setup.outputs.gh_branch_name }} - BUILDX_DRIVER: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} - BUILDX_VERSION: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} - BUILDX_PLATFORMS: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} - BUILDX_ENDPOINT: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} steps: - - name: Set Admin Docker Tag - run: | - if [ "${{ github.event_name }}" == "release" ]; then - TAG=makeplane/plane-admin:${{ github.event.release.tag_name }} - if [ "${{ env.IS_PRERELEASE }}" != "true" ]; then - TAG=${TAG},makeplane/plane-admin:stable - fi - elif [ "${{ env.TARGET_BRANCH }}" == "master" ]; then - TAG=makeplane/plane-admin:latest - else - TAG=${{ env.ADMIN_TAG }} - fi - echo "ADMIN_TAG=${TAG}" >> $GITHUB_ENV - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: ${{ env.BUILDX_DRIVER }} - version: ${{ env.BUILDX_VERSION }} - endpoint: ${{ env.BUILDX_ENDPOINT }} - - - name: Check out the repo + - id: checkout_files + name: Checkout Files uses: actions/checkout@v4 - - - name: Build and Push Frontend to Docker Container Registry - uses: docker/build-push-action@v5.1.0 + - name: Web Build and Push + uses: ./.github/actions/build-push-action with: - context: . - file: ./admin/Dockerfile.admin - platforms: ${{ env.BUILDX_PLATFORMS }} - tags: ${{ env.ADMIN_TAG }} - push: true - env: - DOCKER_BUILDKIT: 1 - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + build-release: ${{ needs.branch_build_setup.outputs.build_release }} + build-prerelease: ${{ needs.branch_build_setup.outputs.build_prerelease }} + release-version: ${{ needs.branch_build_setup.outputs.release_version }} + docker-username: ${{ secrets.DOCKERHUB_USERNAME }} + docker-token: ${{ secrets.DOCKERHUB_TOKEN }} + docker-image-owner: makeplane + docker-image-name: ${{ needs.branch_build_setup.outputs.dh_img_web }} + build-context: . + dockerfile-path: ./web/Dockerfile.web + buildx-driver: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} + buildx-version: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} + buildx-platforms: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} + buildx-endpoint: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} branch_build_push_space: - if: ${{ needs.branch_build_setup.outputs.build_space == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} + if: ${{ needs.branch_build_setup.outputs.build_space == 'true' || github.event_name == 'workflow_dispatch' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} name: Build-Push Space Docker Image runs-on: ubuntu-20.04 needs: [branch_build_setup] - env: - SPACE_TAG: makeplane/plane-space:${{ needs.branch_build_setup.outputs.flat_branch_name }} - TARGET_BRANCH: ${{ needs.branch_build_setup.outputs.gh_branch_name }} - BUILDX_DRIVER: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} - BUILDX_VERSION: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} - BUILDX_PLATFORMS: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} - BUILDX_ENDPOINT: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} steps: - - name: Set Space Docker Tag - run: | - if [ "${{ github.event_name }}" == "release" ]; then - TAG=makeplane/plane-space:${{ github.event.release.tag_name }} - if [ "${{ env.IS_PRERELEASE }}" != "true" ]; then - TAG=${TAG},makeplane/plane-space:stable - fi - elif [ "${{ env.TARGET_BRANCH }}" == "master" ]; then - TAG=makeplane/plane-space:latest - else - TAG=${{ env.SPACE_TAG }} - fi - echo "SPACE_TAG=${TAG}" >> $GITHUB_ENV - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: ${{ env.BUILDX_DRIVER }} - version: ${{ env.BUILDX_VERSION }} - endpoint: ${{ env.BUILDX_ENDPOINT }} - - - name: Check out the repo + - id: checkout_files + name: Checkout Files uses: actions/checkout@v4 - - - name: Build and Push Space to Docker Hub - uses: docker/build-push-action@v5.1.0 + - name: Space Build and Push + uses: ./.github/actions/build-push-action with: - context: . - file: ./space/Dockerfile.space - platforms: ${{ env.BUILDX_PLATFORMS }} - tags: ${{ env.SPACE_TAG }} - push: true - env: - DOCKER_BUILDKIT: 1 - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + build-release: ${{ needs.branch_build_setup.outputs.build_release }} + build-prerelease: ${{ needs.branch_build_setup.outputs.build_prerelease }} + release-version: ${{ needs.branch_build_setup.outputs.release_version }} + docker-username: ${{ secrets.DOCKERHUB_USERNAME }} + docker-token: ${{ secrets.DOCKERHUB_TOKEN }} + docker-image-owner: makeplane + docker-image-name: ${{ needs.branch_build_setup.outputs.dh_img_space }} + build-context: . + dockerfile-path: ./space/Dockerfile.space + buildx-driver: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} + buildx-version: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} + buildx-platforms: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} + buildx-endpoint: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} - branch_build_push_apiserver: - if: ${{ needs.branch_build_setup.outputs.build_apiserver == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} - name: Build-Push API Server Docker Image + branch_build_push_live: + if: ${{ needs.branch_build_setup.outputs.build_live == 'true' || github.event_name == 'workflow_dispatch' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} + name: Build-Push Live Collaboration Docker Image runs-on: ubuntu-20.04 needs: [branch_build_setup] - env: - BACKEND_TAG: makeplane/plane-backend:${{ needs.branch_build_setup.outputs.flat_branch_name }} - TARGET_BRANCH: ${{ needs.branch_build_setup.outputs.gh_branch_name }} - BUILDX_DRIVER: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} - BUILDX_VERSION: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} - BUILDX_PLATFORMS: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} - BUILDX_ENDPOINT: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} steps: - - name: Set Backend Docker Tag - run: | - if [ "${{ github.event_name }}" == "release" ]; then - TAG=makeplane/plane-backend:${{ github.event.release.tag_name }} - if [ "${{ env.IS_PRERELEASE }}" != "true" ]; then - TAG=${TAG},makeplane/plane-backend:stable - fi - elif [ "${{ env.TARGET_BRANCH }}" == "master" ]; then - TAG=makeplane/plane-backend:latest - else - TAG=${{ env.BACKEND_TAG }} - fi - echo "BACKEND_TAG=${TAG}" >> $GITHUB_ENV - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: ${{ env.BUILDX_DRIVER }} - version: ${{ env.BUILDX_VERSION }} - endpoint: ${{ env.BUILDX_ENDPOINT }} - - - name: Check out the repo + - id: checkout_files + name: Checkout Files uses: actions/checkout@v4 - - - name: Build and Push Backend to Docker Hub - uses: docker/build-push-action@v5.1.0 + - name: Live Build and Push + uses: ./.github/actions/build-push-action with: - context: ./apiserver - file: ./apiserver/Dockerfile.api - platforms: ${{ env.BUILDX_PLATFORMS }} - push: true - tags: ${{ env.BACKEND_TAG }} - env: - DOCKER_BUILDKIT: 1 - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + build-release: ${{ needs.branch_build_setup.outputs.build_release }} + build-prerelease: ${{ needs.branch_build_setup.outputs.build_prerelease }} + release-version: ${{ needs.branch_build_setup.outputs.release_version }} + docker-username: ${{ secrets.DOCKERHUB_USERNAME }} + docker-token: ${{ secrets.DOCKERHUB_TOKEN }} + docker-image-owner: makeplane + docker-image-name: ${{ needs.branch_build_setup.outputs.dh_img_live }} + build-context: . + dockerfile-path: ./live/Dockerfile.live + buildx-driver: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} + buildx-version: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} + buildx-platforms: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} + buildx-endpoint: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} - branch_build_push_live: - if: ${{ needs.branch_build_setup.outputs.build_live == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} - name: Build-Push Live Collaboration Docker Image + branch_build_push_apiserver: + if: ${{ needs.branch_build_setup.outputs.build_apiserver == 'true' || github.event_name == 'workflow_dispatch' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} + name: Build-Push API Server Docker Image runs-on: ubuntu-20.04 needs: [branch_build_setup] - env: - LIVE_TAG: makeplane/plane-live:${{ needs.branch_build_setup.outputs.flat_branch_name }} - TARGET_BRANCH: ${{ needs.branch_build_setup.outputs.gh_branch_name }} - BUILDX_DRIVER: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} - BUILDX_VERSION: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} - BUILDX_PLATFORMS: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} - BUILDX_ENDPOINT: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} steps: - - name: Set Live Docker Tag - run: | - if [ "${{ github.event_name }}" == "release" ]; then - TAG=makeplane/plane-live:${{ github.event.release.tag_name }} - if [ "${{ github.event.release.prerelease }}" != "true" ]; then - TAG=${TAG},makeplane/plane-live:stable - fi - elif [ "${{ env.TARGET_BRANCH }}" == "master" ]; then - TAG=makeplane/plane-live:latest - else - TAG=${{ env.LIVE_TAG }} - fi - echo "LIVE_TAG=${TAG}" >> $GITHUB_ENV - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: ${{ env.BUILDX_DRIVER }} - version: ${{ env.BUILDX_VERSION }} - endpoint: ${{ env.BUILDX_ENDPOINT }} - - - name: Check out the repo + - id: checkout_files + name: Checkout Files uses: actions/checkout@v4 - - - name: Build and Push Live Server to Docker Hub - uses: docker/build-push-action@v5.1.0 + - name: Backend Build and Push + uses: ./.github/actions/build-push-action with: - context: . - file: ./live/Dockerfile.live - platforms: ${{ env.BUILDX_PLATFORMS }} - tags: ${{ env.LIVE_TAG }} - push: true - env: - DOCKER_BUILDKIT: 1 - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + build-release: ${{ needs.branch_build_setup.outputs.build_release }} + build-prerelease: ${{ needs.branch_build_setup.outputs.build_prerelease }} + release-version: ${{ needs.branch_build_setup.outputs.release_version }} + docker-username: ${{ secrets.DOCKERHUB_USERNAME }} + docker-token: ${{ secrets.DOCKERHUB_TOKEN }} + docker-image-owner: makeplane + docker-image-name: ${{ needs.branch_build_setup.outputs.dh_img_backend }} + build-context: ./apiserver + dockerfile-path: ./apiserver/Dockerfile.api + buildx-driver: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} + buildx-version: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} + buildx-platforms: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} + buildx-endpoint: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} branch_build_push_proxy: - if: ${{ needs.branch_build_setup.outputs.build_proxy == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'release' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} + if: ${{ needs.branch_build_setup.outputs.build_proxy == 'true' || github.event_name == 'workflow_dispatch' || needs.branch_build_setup.outputs.gh_branch_name == 'master' }} name: Build-Push Proxy Docker Image runs-on: ubuntu-20.04 needs: [branch_build_setup] - env: - PROXY_TAG: makeplane/plane-proxy:${{ needs.branch_build_setup.outputs.flat_branch_name }} - TARGET_BRANCH: ${{ needs.branch_build_setup.outputs.gh_branch_name }} - BUILDX_DRIVER: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} - BUILDX_VERSION: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} - BUILDX_PLATFORMS: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} - BUILDX_ENDPOINT: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} steps: - - name: Set Proxy Docker Tag - run: | - if [ "${{ github.event_name }}" == "release" ]; then - TAG=makeplane/plane-proxy:${{ github.event.release.tag_name }} - if [ "${{ env.IS_PRERELEASE }}" != "true" ]; then - TAG=${TAG},makeplane/plane-proxy:stable - fi - elif [ "${{ env.TARGET_BRANCH }}" == "master" ]; then - TAG=makeplane/plane-proxy:latest - else - TAG=${{ env.PROXY_TAG }} - fi - echo "PROXY_TAG=${TAG}" >> $GITHUB_ENV - - - name: Login to Docker Hub - uses: docker/login-action@v3 + - id: checkout_files + name: Checkout Files + uses: actions/checkout@v4 + - name: Proxy Build and Push + uses: ./.github/actions/build-push-action with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + build-release: ${{ needs.branch_build_setup.outputs.build_release }} + build-prerelease: ${{ needs.branch_build_setup.outputs.build_prerelease }} + release-version: ${{ needs.branch_build_setup.outputs.release_version }} + docker-username: ${{ secrets.DOCKERHUB_USERNAME }} + docker-token: ${{ secrets.DOCKERHUB_TOKEN }} + docker-image-owner: makeplane + docker-image-name: ${{ needs.branch_build_setup.outputs.dh_img_proxy }} + build-context: ./nginx + dockerfile-path: ./nginx/Dockerfile + buildx-driver: ${{ needs.branch_build_setup.outputs.gh_buildx_driver }} + buildx-version: ${{ needs.branch_build_setup.outputs.gh_buildx_version }} + buildx-platforms: ${{ needs.branch_build_setup.outputs.gh_buildx_platforms }} + buildx-endpoint: ${{ needs.branch_build_setup.outputs.gh_buildx_endpoint }} + + attach_assets_to_build: + if: ${{ needs.branch_build_setup.outputs.build_type == 'Build' }} + name: Attach Assets to Build + runs-on: ubuntu-20.04 + needs: [ branch_build_setup ] + steps: + - name: Checkout + uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: ${{ env.BUILDX_DRIVER }} - version: ${{ env.BUILDX_VERSION }} - endpoint: ${{ env.BUILDX_ENDPOINT }} + - name: Update Assets + run: | + cp ./deploy/selfhost/install.sh deploy/selfhost/setup.sh - - name: Check out the repo + - name: Attach Assets + id: attach_assets + uses: actions/upload-artifact@v4 + with: + name: selfhost-assets + retention-days: 2 + path: | + ${{ github.workspace }}/deploy/selfhost/setup.sh + ${{ github.workspace }}/deploy/selfhost/restore.sh + ${{ github.workspace }}/deploy/selfhost/docker-compose.yml + ${{ github.workspace }}/deploy/selfhost/variables.env + + publish_release: + if: ${{ needs.branch_build_setup.outputs.build_type == 'Release' }} + name: Build Release + runs-on: ubuntu-20.04 + needs: + [ + branch_build_setup, + branch_build_push_admin, + branch_build_push_web, + branch_build_push_space, + branch_build_push_live, + branch_build_push_apiserver, + branch_build_push_proxy + ] + env: + REL_VERSION: ${{ needs.branch_build_setup.outputs.release_version }} + steps: + - name: Checkout uses: actions/checkout@v4 - - name: Build and Push Plane-Proxy to Docker Hub - uses: docker/build-push-action@v5.1.0 - with: - context: ./nginx - file: ./nginx/Dockerfile - platforms: ${{ env.BUILDX_PLATFORMS }} - tags: ${{ env.PROXY_TAG }} - push: true + - name: Update Assets + run: | + cp ./deploy/selfhost/install.sh deploy/selfhost/setup.sh + + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v2.0.8 env: - DOCKER_BUILDKIT: 1 - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ env.REL_VERSION }} + name: ${{ env.REL_VERSION }} + draft: false + prerelease: ${{ env.IS_PRERELEASE }} + generate_release_notes: true + files: | + ${{ github.workspace }}/deploy/selfhost/setup.sh + ${{ github.workspace }}/deploy/selfhost/restore.sh + ${{ github.workspace }}/deploy/selfhost/docker-compose.yml + ${{ github.workspace }}/deploy/selfhost/variables.env \ No newline at end of file