diff --git a/.github/workflows/busybox.yaml b/.github/workflows/busybox.yaml deleted file mode 100644 index ada1a3d74..000000000 --- a/.github/workflows/busybox.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# A special manual workflow to push a busybox image into our public ecr registry. This image is used for the init helper containers -name: Push busybox image to ecr -on: workflow_dispatch - - -jobs: - release: - name: Push busybox image to ecr - runs-on: ubuntu-latest - environment: - name: k8s-operator - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Pull and Push docker image - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd opensearch-operator - export IMG=public.ecr.aws/opsterio/busybox:1.27.2-buildx - echo $IMG - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opsterio - docker buildx build -f Dockerfile-busybox --platform="linux/amd64,linux/arm,linux/arm64" . -t $IMG --push - cd .. diff --git a/.github/workflows/prepare-release.yaml b/.github/workflows/prepare-release.yaml deleted file mode 100644 index f9d791d24..000000000 --- a/.github/workflows/prepare-release.yaml +++ /dev/null @@ -1,88 +0,0 @@ -name: Prepare and publish release -on: - workflow_dispatch: - inputs: - version: - description: 'Version for the release, semver, NO "v" prefix' - required: true - type: string - -jobs: - release: - name: Prepare and publish release - runs-on: ubuntu-latest - environment: - name: k8s-operator - steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Setup go - uses: actions/setup-go@v3 - with: - go-version: "1.19" - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Run tests - run: | - # Run test suite to make sure we have a functional commit - cd opensearch-operator - make manifests test - cd .. - - name: Prepare helm chart - run: | - # Copy CRDs to chart to make sure they are identical - cp opensearch-operator/config/crd/bases/opensearch.opster.io_*.yaml charts/opensearch-operator/files/ - # Set versions in helm chart - sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml - sed -i -e 's/^version:.*/version: '$RELEASE_VERSION'/' charts/opensearch-operator/Chart.yaml - sed -i -e 's/^appVersion:.*/appVersion: '$RELEASE_VERSION'/' charts/opensearch-cluster/Chart.yaml - sed -i -e 's/^version:.*/version: '$RELEASE_VERSION'/' charts/opensearch-cluster/Chart.yaml - # Commit changes - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - git add charts - if git commit -m "Prepare for release $RELEASE_VERSION"; then - git push origin main - fi - # Create tag, this will not trigger the other release pipeline - git tag v$RELEASE_VERSION - git push --tags - env: - RELEASE_VERSION: ${{ inputs.version }} - - - name: Build and Push docker image - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - RELEASE_VERSION: ${{ inputs.version }} - run: | - cd opensearch-operator - export IMG=public.ecr.aws/opsterio/opensearch-operator:$RELEASE_VERSION - echo $IMG - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opsterio - docker buildx build -t $IMG --platform="linux/amd64,linux/arm,linux/arm64" . -f Dockerfile --push - cd .. - - - name: Install Helm - uses: azure/setup-helm@v1 - with: - version: v3.8.1 - - - name: Publish helm chart - uses: stefanprodan/helm-gh-pages@master - with: - charts_dir: charts/ - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: v${{ inputs.version }} - release_name: ${{ inputs.version }} - draft: true - prerelease: false diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 295cc77f6..5f0873d76 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,7 +2,7 @@ name: "Publish Release from tag" on: push: tags: - - 'v*' + - '*' jobs: release: runs-on: ubuntu-latest @@ -21,36 +21,7 @@ jobs: - name: set Env id: github-ver run: | - echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV - - - name: Build and Push operator docker image - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd opensearch-operator - make test - export IMG=public.ecr.aws/opensearch-project/opensearch-operator:$RELEASE_VERSION - echo $IMG - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opsterio - docker buildx build -t $IMG --platform="linux/amd64,linux/arm,linux/arm64" . -f Dockerfile --push - cd .. - - - name: Pull and Push operator busybox docker image - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - cd opensearch-operator - export IMG=public.ecr.aws/opensearch-project/opensearch-operator-busybox:$RELEASE_VERSION - echo $IMG - aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/opsterio - docker buildx build -f Dockerfile-busybox --platform="linux/amd64,linux/arm,linux/arm64" . -t $IMG --push - cd .. + echo "RELEASE_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV - name: Make sure helm chart has correct versions run: | diff --git a/jenkins/release.jenkinsfile b/jenkins/release.jenkinsfile index e4b6edd16..29c6be359 100644 --- a/jenkins/release.jenkinsfile +++ b/jenkins/release.jenkinsfile @@ -42,7 +42,6 @@ pipeline { causeString: 'A commit was pushed on opensearch-project/opensearch-k8s-operator repository main branch causing this workflow to run', printContributedVariables: false, printPostContent: false, - regexpFilterText: '$isTag', ) } environment { @@ -55,7 +54,6 @@ pipeline { steps { script { def ref_final = "${GIT_REFERENCE}" - println("the ref_final was : ${ref_final}") def ref_url = "${REPO_URL}/commit/${GIT_REFERENCE}" if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) { ref_final = "${ref}" @@ -89,15 +87,14 @@ pipeline { string(name: 'DOCKER_BUILD_GIT_REPOSITORY', value: "${REPO_URL}"), string(name: 'DOCKER_BUILD_GIT_REPOSITORY_REFERENCE', value: "${ref_final}"), string(name: 'DOCKER_BUILD_SCRIPT_WITH_COMMANDS', value: [ - 'id', - 'pwd', 'ls -l', + 'cd opensearch-operator', [ 'bash', - 'scripts/build-image-multi-arch.sh', + '../scripts/build-image-multi-arch.sh', "-v ${OPERATOR_VERSION}", "-a 'x64,arm,arm64'", - "-f opensearch-operator/Dockerfile-busybox", + "-f Dockerfile-busybox", "-p ${OPERATOR_PRODUCT}" ].join(' ') ].join(' && ')), @@ -121,5 +118,73 @@ pipeline { } } } + stage('OpenSearch Operator') { + steps { + script { + def ref_final = "${GIT_REFERENCE}" + def ref_url = "${REPO_URL}/commit/${GIT_REFERENCE}" + if (env.USER_BUILD_CAUSE.equals('[]') && env.TIMER_BUILD_CAUSE.equals('[]')) { + ref_final = "${ref}" + ref_url = "${REPO_URL}/releases/tag/${ref}" + println("Triggered by GitHub: ${ref_url}") + + currentBuild.description = """GitHub: ${ref_url}""" + } + else { + println("Triggered by User/Timer: ${ref_url}") + currentBuild.description = """User/Timer: ${ref_url}""" + } + + if (ref_final == null || ref_final == '') { + currentBuild.result = 'ABORTED' + error("Missing git tag reference.") + } + + echo("Git checkout ${REPO_URL} on ${ref_final} for opensearch-operator-busybox release") + checkout scm + sh("git checkout ${ref_final}") + + def OPERATOR_PRODUCT = "opensearch-operator" + def OPERATOR_VERSION = "$ref_final" + + echo("${OPERATOR_PRODUCT}: ${OPERATOR_VERSION}") + + dockerBuild: { + build job: 'docker-build', + parameters: [ + string(name: 'DOCKER_BUILD_GIT_REPOSITORY', value: "${REPO_URL}"), + string(name: 'DOCKER_BUILD_GIT_REPOSITORY_REFERENCE', value: "${ref_final}"), + string(name: 'DOCKER_BUILD_SCRIPT_WITH_COMMANDS', value: [ + 'ls -l', + 'cd opensearch-operator', + [ + 'bash', + '../scripts/build-image-multi-arch.sh', + "-v ${OPERATOR_VERSION}", + "-a 'x64,arm,arm64'", + "-f Dockerfile", + "-p ${OPERATOR_PRODUCT}" + ].join(' ') + ].join(' && ')), + ] + } + dockerPromotion: { + build job: 'docker-promotion', + parameters: [ + string(name: 'SOURCE_IMAGES', value: '${OPERATOR_PRODUCT}:${OPERATOR_VERSION}'), + string(name: 'RELEASE_VERSION', value: "${OPERATOR_VERSION}"), + string(name: 'DOCKER_HUB_PROMOTE', value: true), + string(name: 'ECR_PROMOTE', value: true), + string(name: 'TAG_LATEST', value: true) + ] + } + } + } + post { + always { + cleanWs disableDeferredWipeout: true, deleteDirs: true + } + } + } } } diff --git a/scripts/build-image-multi-arch.sh b/scripts/build-image-multi-arch.sh index 389f12772..a38338306 100644 --- a/scripts/build-image-multi-arch.sh +++ b/scripts/build-image-multi-arch.sh @@ -135,4 +135,4 @@ docker ps | grep $BUILDER_NAME # Build multi-arch images PLATFORMS=`echo "${ARCHITECTURE_ARRAY[@]/#/linux/}" | sed 's/x64/amd64/g;s/ /,/g'` && echo PLATFORMS $PLATFORMS -docker buildx build --platform $PLATFORMS --build-arg VERSION=$VERSION --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` --build-arg NOTES=$NOTES -t pgodithi/opensearchproject/$PRODUCT:${VERSION} -f $DOCKERFILE . --push +docker buildx build --platform $PLATFORMS --build-arg VERSION=$VERSION --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` --build-arg NOTES=$NOTES -t opensearchstaging/$PRODUCT:${VERSION} -f $DOCKERFILE . --push