diff --git a/.github/workflows/cut-release-common.yml b/.github/workflows/cut-release-common.yml index a12d37c..49a4be6 100644 --- a/.github/workflows/cut-release-common.yml +++ b/.github/workflows/cut-release-common.yml @@ -12,6 +12,10 @@ on: required: true type: boolean default: false + build_command: + description: 'Command to run to build' + type: string + required: false install_command: description: 'Command to run to install dependencies' type: string @@ -24,6 +28,14 @@ on: required: false type: boolean default: false + include_chart: + required: false + type: boolean + default: false + needs_docker: + required: false + type: boolean + default: false env: description: 'Deployment namespace/environment' required: false @@ -246,6 +258,103 @@ jobs: commit_message: Rev'd main to Release ${{ env.VERSION }} branch: main + cutReleaseCandidateGo: + needs: detect-language + runs-on: ubuntu-latest + outputs: + branch: ${{ steps.set-branch.outputs.branch }} + if: needs.detect-language.outputs.language == 'go' + steps: + - uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.GH_PAT }} + + - name: Set Repo Name + run: echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV + + - name: Set Repo Name in Camel Case + run: | + repo_name=$(basename ${{ github.repository }}) + camel_case_name=$(echo $repo_name | awk -F- '{for(i=2; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2); }1' OFS="") + echo "CAMEL_CASE_REPO_NAME=$camel_case_name" >> $GITHUB_ENV + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20' # This will install the latest stable Node.js version + + - name: Log Node and Npm Versions + run: | + echo node version $(node -v) + echo npm version $(npm -v) + + - name: install semver globally + run: npm install -g semver + + - name: Debug deploy config + run: | + echo cloud_deploy: ${{ inputs.cloud_deploy }} + echo skip_deploy: ${{ inputs.skip_deploy }} + echo env: ${{ inputs.env }} + + - name: Update Version + run: | + echo "v$(semver -i prerelease $(sed 's/^v//' VERSION) --preid=rc)" > VERSION + echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV + + - name: Update Chart.yaml version + if: ${{ inputs.include_chart }} + run: yq eval -P -i ".appVersion=\"${{ env.VERSION }}\"" ./helm/Chart.yaml + + - name: Update values.yaml version + if: ${{ inputs.include_chart }} + run: yq eval -P -i ".${{ env.CAMEL_CASE_REPO_NAME }}.image.version=\"${{ env.VERSION }}\"" ./helm/values.yaml + + - name: Update version environment variable + run: echo "VERSION=$(echo $VERSION | sed 's/\.[0-9]*-.*//g')" >> $GITHUB_ENV + + - name: Store version in branch variable + id: set-branch + run: echo "branch=${{ env.VERSION }}" >> $GITHUB_OUTPUT + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Release ${{ env.VERSION }} + branch: ${{ env.VERSION }} + create_branch: true + + - uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.GH_PAT }} + + - name: Set Repo Name + run: echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV + + - name: Set Repo Name in Camel Case + run: | + repo_name=$(basename ${{ github.repository }}) + camel_case_name=$(echo $repo_name | awk -F- '{for(i=2; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2); }1' OFS="") + echo "CAMEL_CASE_REPO_NAME=$camel_case_name" >> $GITHUB_ENV + + - name: Update Version + run: | + echo "v$(semver -i preminor $(sed 's/^v//' VERSION) --preid=pre)" > VERSION + echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV + + - name: Update Chart.yaml version + if: ${{ inputs.include_chart }} + run: yq eval -P -i ".appVersion=\"${{ env.VERSION }}\"" ./helm/Chart.yaml + + - name: Update values.yaml version + if: ${{ inputs.include_chart }} + run: yq eval -P -i ".${{ env.CAMEL_CASE_REPO_NAME }}.image.version=\"${{ env.VERSION }}\"" ./helm/values.yaml + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: Rev'd main to Release ${{ env.VERSION }} + branch: main + + deployReleaseCandidateJS: uses: ./.github/workflows/build-deploy-js.yml needs: [cutReleaseCandidateJS] @@ -287,3 +396,28 @@ jobs: needs_build: ${{ inputs.needs_build }} install_command: ${{ inputs.install_command }} skip_deploy: ${{ inputs.skip_deploy }} + + deployReleaseCandidateGo: + uses: ./.github/workflows/build-deploy-go.yml + needs: [cutReleaseCandidateGo] + if: needs.detect-language.outputs.language == 'go' + secrets: + DOCKER: ${{ secrets.DOCKER }} + GH_PAT: ${{ secrets.GH_PAT }} + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + DOCKER_BUILD_ARGS: ${{ secrets.DOCKER_BUILD_ARGS }} + BUILD_ARGS: ${{ secrets.BUILD_ARGS }} + with: + env: ${{ inputs.env }} + update_version_command: "echo \"v$(semver -i prerelease $(sed 's/^v//' VERSION) --preid=rc)\" > VERSION" + branch: ${{ needs.cutReleaseCandidateJS.outputs.branch }} + rails: '[[ "$VERSION" =~ "rc" ]]' + update_version: true + cloud_deploy: ${{ inputs.cloud_deploy }} + needs_build: ${{ inputs.needs_build }} + install_command: ${{ inputs.install_command }} + skip_deploy: ${{ inputs.skip_deploy }} + build_command: ${{ inputs.build_command }} + needs_docker: ${{ inputs.needs_docker }} + include_chart: ${{ inputs.include_chart }} + diff --git a/.github/workflows/deploy-prod-common.yml b/.github/workflows/deploy-prod-common.yml index 8d8fd9d..3e608ca 100644 --- a/.github/workflows/deploy-prod-common.yml +++ b/.github/workflows/deploy-prod-common.yml @@ -23,6 +23,18 @@ on: required: false type: string default: quai-prod + build_command: + description: 'Command to run to build' + type: string + required: false + needs_docker: + required: false + type: boolean + default: false + include_chart: + required: false + type: boolean + default: false secrets: GH_PAT: description: 'needed for github login' @@ -158,6 +170,56 @@ jobs: commit_message: "Prod Release ${{ env.VERSION }}" branch: ${{ github.ref }} + createProdTagGo: + needs: detect-language + runs-on: ubuntu-latest + if: needs.detect-language.outputs.language == 'go' + steps: + - uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.GH_PAT }} + + - name: Set Repo Name + run: echo "REPO_NAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV + + - name: Set Repo Name in Camel Case + run: | + repo_name=$(basename ${{ github.repository }}) + camel_case_name=$(echo $repo_name | awk -F- '{for(i=2; i<=NF; i++) $i=toupper(substr($i,1,1)) substr($i,2); }1' OFS="") + echo "CAMEL_CASE_REPO_NAME=$camel_case_name" >> $GITHUB_ENV + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '20' # This will install the latest stable Node.js version + + - name: Log Node and Npm Versions + run: | + echo node version $(node -v) + echo npm version $(npm -v) + + - name: install semver globally + run: npm install -g semver + + - name: Update Version + run: | + echo "v$(semver -i patch $(sed 's/^v//' VERSION))" > VERSION + echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV + + - name: Update Chart.yaml version + if: ${{ inputs.include_chart }} + run: yq eval -i ".appVersion=\"${{ env.VERSION }}\"" ./helm/Chart.yaml + + - name: Update values.yaml version + if: ${{ inputs.include_chart }} + run: yq eval -i ".${{ env.CAMEL_CASE_REPO_NAME }}.image.version=\"${{ env.VERSION }}\"" ./helm/values.yaml + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Prod Release ${{ env.VERSION }}" + branch: ${{ github.ref }} + + buildDeployProdJS: needs: [createProdTagJS] uses: ./.github/workflows/build-deploy-js.yml @@ -195,3 +257,25 @@ jobs: needs_build: ${{ inputs.needs_build }} install_command: ${{ inputs.install_command }} skip_deploy: ${{ inputs.skip_deploy }} + + buildDeployProdGo: + needs: [createProdTagGo] + uses: ./.github/workflows/build-deploy-go.yml + secrets: + DOCKER: ${{ secrets.DOCKER }} + GH_PAT: ${{ secrets.GH_PAT }} + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + DOCKER_BUILD_ARGS: ${{ secrets.DOCKER_BUILD_ARGS }} + BUILD_ARGS: ${{ secrets.BUILD_ARGS }} + with: + env: ${{ inputs.env }} + update_version_command: "echo \"v$(semver -i prepatch $(sed 's/^v//' VERSION) --preid=rc)\" > VERSION" + rails: '[[ ! "$VERSION" =~ "rc" ]] && [[ ! "$VERSION" =~ "pre" ]]' + update_version: true + cloud_deploy: ${{ inputs.cloud_deploy }} + needs_build: ${{ inputs.needs_build }} + install_command: ${{ inputs.install_command }} + skip_deploy: ${{ inputs.skip_deploy }} + build_command: ${{ inputs.build_command }} + needs_docker: ${{ inputs.needs_docker }} + include_chart: ${{ inputs.include_chart }} diff --git a/.github/workflows/deploy-sandbox-common.yml b/.github/workflows/deploy-sandbox-common.yml index 833cdd5..9745f6e 100644 --- a/.github/workflows/deploy-sandbox-common.yml +++ b/.github/workflows/deploy-sandbox-common.yml @@ -23,6 +23,18 @@ on: required: false type: string default: quai-sandbox + build_command: + description: 'Command to run to build' + type: string + required: false + needs_docker: + required: false + type: boolean + default: false + include_chart: + required: false + type: boolean + default: false secrets: GH_PAT: description: 'needed for github login' @@ -104,3 +116,26 @@ jobs: needs_build: ${{ inputs.needs_build }} install_command: ${{ inputs.install_command }} skip_deploy: ${{ inputs.skip_deploy }} + + buildDeploySandboxGo: + needs: detect-language + if: github.event.pull_request.merged == true && needs.detect-language.outputs.language == 'go' + uses: ./.github/workflows/build-deploy-go.yml + secrets: + DOCKER: ${{ secrets.DOCKER }} + GH_PAT: ${{ secrets.GH_PAT }} + KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} + DOCKER_BUILD_ARGS: ${{ secrets.DOCKER_BUILD_ARGS }} + BUILD_ARGS: ${{ secrets.BUILD_ARGS }} + with: + env: ${{ inputs.env }} + update_version_command: "echo \"v$(semver -i prerelease $(sed 's/^v//' VERSION) --preid=rc)\" > VERSION" + rails: '[[ ! "$VERSION" =~ "pre" ]]' + update_version: true + cloud_deploy: ${{ inputs.cloud_deploy }} + needs_build: ${{ inputs.needs_build }} + install_command: ${{ inputs.install_command }} + skip_deploy: ${{ inputs.skip_deploy }} + build_command: ${{ inputs.build_command }} + needs_docker: ${{ inputs.needs_docker }} + include_chart: ${{ inputs.include_chart }} diff --git a/.github/workflows/test-remote-dev-manual-workflow.yml b/.github/workflows/test-remote-dev-manual-workflow.yml index d3282f0..73d7e7d 100644 --- a/.github/workflows/test-remote-dev-manual-workflow.yml +++ b/.github/workflows/test-remote-dev-manual-workflow.yml @@ -11,12 +11,15 @@ jobs: uses: dominant-strategies/quai-cicd/.github/workflows/deploy-dev-common.yml@main with: needs_build: true - install_command: "npm ci" + build_command: "make go-quai" + needs_docker: false + include_chart: false cloud_deploy: false skip_deploy: true + secrets: DOCKER: ${{ secrets.DOCKER }} GH_PAT: ${{ secrets.GH_PAT }} KUBE_CONFIG: ${{ secrets.KUBECONFIG_LOCAL }} - BUILD_ARGS: 'BUILD_ENV=production' DOCKER_BUILD_ARGS: 'BUILD_ENV=quai-dev,LOCAL_GCP_CAPTCHA=${{ secrets.LOCAL_GCP_CAPTCHA }}' +