diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f7929e0e7a..09df415072 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,6 +8,7 @@ on: env: GRADLE_OPTS: -Dorg.gradle.daemon=false -Xmx6g -Xms6g + CONTAINER_REGISTRY: us-docker.pkg.dev/spinnaker-community/docker jobs: branch-build: @@ -21,5 +22,44 @@ jobs: java-version: 11 distribution: 'zulu' cache: 'gradle' + - name: Extract repository name + id: extract_repo_name + run: echo ::set-output name=REPO::${GITHUB_REPOSITORY##*/} - name: Build - run: ./gradlew build --stacktrace + run: ./gradlew build --stacktrace ${{ steps.extract_repo_name.outputs.REPO }}-web:installDist + - name: Get date + id: get_date + run: echo ::set-output name=DATETIME::$(date --utc +'%Y%m%d%H%M') + - name: Login to GAR + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/login-action@v1 + # use service account flow defined at: https://github.com/docker/login-action#service-account-based-authentication-1 + with: + registry: us-docker.pkg.dev + username: _json_key + password: ${{ secrets.GAR_JSON_KEY }} + - name: Build and publish slim container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile.slim + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.ref_name }}-${{ github.sha }}-${{ steps.get_date.outputs.DATETIME }}-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.ref_name }}-${{ github.sha }}-${{ steps.get_date.outputs.DATETIME }}-unvalidated-slim" + - name: Build and publish ubuntu container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile.ubuntu + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.ref_name }}-latest-unvalidated-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.ref_name }}-${{ github.sha }}-${{ steps.get_date.outputs.DATETIME }}-unvalidated-ubuntu" diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 02d922655e..bcdfe38694 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -4,6 +4,7 @@ on: [ pull_request ] env: GRADLE_OPTS: -Dorg.gradle.daemon=false -Xmx6g -Xms6g + CONTAINER_REGISTRY: us-docker.pkg.dev/spinnaker-community/docker jobs: build: @@ -15,5 +16,29 @@ jobs: java-version: 11 distribution: 'zulu' cache: 'gradle' + - name: Extract repository name + id: extract_repo_name + run: echo ::set-output name=REPO::${GITHUB_REPOSITORY##*/} - name: Build - run: ./gradlew build + run: ./gradlew build ${{ steps.extract_repo_name.outputs.REPO }}-web:installDist + - name: Get date + id: get_date + run: echo ::set-output name=DATETIME::$(date --utc +'%Y%m%d%H%M') + - name: Build slim container image + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile.slim + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:latest" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.sha }}-${{ steps.get_date.outputs.DATETIME }}" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:latest-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.sha }}-${{ steps.get_date.outputs.DATETIME }}-slim" + - name: Build ubuntu container image + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile.ubuntu + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:latest-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ github.sha }}-${{ steps.get_date.outputs.DATETIME }}-ubuntu" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5e65740a81..5feb4343ab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,6 +8,7 @@ on: env: GRADLE_OPTS: -Dorg.gradle.daemon=false -Xmx6g -Xms6g + CONTAINER_REGISTRY: us-docker.pkg.dev/spinnaker-community/docker jobs: release: @@ -30,8 +31,10 @@ jobs: echo ::set-output name=SKIP_RELEASE::${SKIP_RELEASE} echo ::set-output name=IS_CANDIDATE::${IS_CANDIDATE} echo ::set-output name=RELEASE_VERSION::${RELEASE_VERSION} + - name: Extract repository name + id: extract_repo_name + run: echo ::set-output name=REPO::${GITHUB_REPOSITORY##*/} - name: Release build - if: steps.release_info.outputs.IS_CANDIDATE == 'false' env: ORG_GRADLE_PROJECT_version: ${{ steps.release_info.outputs.RELEASE_VERSION }} ORG_GRADLE_PROJECT_nexusPublishEnabled: true @@ -40,7 +43,49 @@ jobs: ORG_GRADLE_PROJECT_nexusPgpSigningKey: ${{ secrets.NEXUS_PGP_SIGNING_KEY }} ORG_GRADLE_PROJECT_nexusPgpSigningPassword: ${{ secrets.NEXUS_PGP_SIGNING_PASSWORD }} run: | - ./gradlew --info publishToNexus closeAndReleaseNexusStagingRepository + ./gradlew --info build ${{ steps.extract_repo_name.outputs.REPO }}-web:installDist publishToNexus closeAndReleaseNexusStagingRepository + - name: Publish apt packages to Google Artifact Registry + env: + ORG_GRADLE_PROJECT_version: ${{ steps.release_info.outputs.RELEASE_VERSION }} + ORG_GRADLE_PROJECT_artifactRegistryPublishEnabled: true + GAR_JSON_KEY: ${{ secrets.GAR_JSON_KEY }} + run: | + ./gradlew --info publish + - name: Get date + id: get_date + run: echo ::set-output name=DATETIME::$(date --utc +'%Y%m%d%H%M') + - name: Login to GAR + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/login-action@v1 + # use service account flow defined at: https://github.com/docker/login-action#service-account-based-authentication-1 + with: + registry: us-docker.pkg.dev + username: _json_key + password: ${{ secrets.GAR_JSON_KEY }} + - name: Build and publish slim container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile.slim + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated-slim" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ github.sha }}-${{ steps.get_date.outputs.DATETIME }}-unvalidated-slim" + - name: Build and publish ubuntu container image + # Only run this on repositories in the 'spinnaker' org, not on forks. + if: startsWith(github.repository, 'spinnaker/') + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile.ubuntu + push: true + tags: | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated-ubuntu" + "${{ env.CONTAINER_REGISTRY }}/${{ steps.extract_repo_name.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ github.sha }}-${{ steps.get_date.outputs.DATETIME }}-unvalidated-ubuntu" - name: Create release if: steps.release_info.outputs.SKIP_RELEASE == 'false' uses: actions/create-release@v1 diff --git a/.github/workflows/release_info.sh b/.github/workflows/release_info.sh index 3cac206d10..0cadf01b76 100755 --- a/.github/workflows/release_info.sh +++ b/.github/workflows/release_info.sh @@ -3,7 +3,6 @@ # Only look to the latest release to determine the previous tag -- this allows us to skip unsupported tag formats (like `version-1.0.0`) export PREVIOUS_TAG=`curl --silent "https://api.github.com/repos/$1/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'` echo "PREVIOUS_TAG=$PREVIOUS_TAG" - export NEW_TAG=${GITHUB_REF/refs\/tags\//} echo "NEW_TAG=$NEW_TAG" export CHANGELOG=`git log $NEW_TAG...$PREVIOUS_TAG --oneline` @@ -31,5 +30,6 @@ SEMVER_REGEX="\ # Used in downstream steps to determine if the release should be marked as a "prerelease" and if the build should build candidate release artifacts export IS_CANDIDATE=`[[ $NEW_TAG =~ $SEMVER_REGEX && ! -z ${BASH_REMATCH[4]} ]] && echo "true" || echo "false"` +# This is the version string we will pass to the build, trim off leading 'v' if present export RELEASE_VERSION=`[[ $NEW_TAG =~ $SEMVER_REGEX ]] && echo "${NEW_TAG:1}" || echo "${NEW_TAG}"` echo "RELEASE_VERSION=$RELEASE_VERSION"