|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v[0-9]+.[0-9]+.[0-9]+" |
| 7 | + - "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+" |
| 8 | + |
| 9 | +env: |
| 10 | + GRADLE_OPTS: -Dorg.gradle.daemon=false -Xmx2g -Xms2g |
| 11 | + CONTAINER_REGISTRY: us-docker.pkg.dev/spinnaker-community/docker |
| 12 | + |
| 13 | +jobs: |
| 14 | + release: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + - uses: actions/setup-java@v2 |
| 21 | + with: |
| 22 | + java-version: 11 |
| 23 | + distribution: 'zulu' |
| 24 | + cache: 'gradle' |
| 25 | + - name: Assemble release info |
| 26 | + id: release_info |
| 27 | + env: |
| 28 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 29 | + run: | |
| 30 | + . .github/workflows/release_info.sh ${{ github.event.repository.full_name }} |
| 31 | + echo ::set-output name=CHANGELOG::$(echo -e "${CHANGELOG}") |
| 32 | + echo ::set-output name=SKIP_RELEASE::${SKIP_RELEASE} |
| 33 | + echo ::set-output name=IS_CANDIDATE::${IS_CANDIDATE} |
| 34 | + echo ::set-output name=RELEASE_VERSION::${RELEASE_VERSION} |
| 35 | + - name: Prepare build variables |
| 36 | + id: build_variables |
| 37 | + run: | |
| 38 | + echo ::set-output name=REPO::monitoring-daemon |
| 39 | + echo ::set-output name=VERSION::"$(git rev-parse --short HEAD)-$(date --utc +'%Y%m%d%H%M')" |
| 40 | + - name: Release build |
| 41 | + env: |
| 42 | + ORG_GRADLE_PROJECT_version: ${{ steps.release_info.outputs.RELEASE_VERSION }} |
| 43 | + ORG_GRADLE_PROJECT_nexusPublishEnabled: true |
| 44 | + ORG_GRADLE_PROJECT_nexusUsername: ${{ secrets.NEXUS_USERNAME }} |
| 45 | + ORG_GRADLE_PROJECT_nexusPassword: ${{ secrets.NEXUS_PASSWORD }} |
| 46 | + ORG_GRADLE_PROJECT_nexusPgpSigningKey: ${{ secrets.NEXUS_PGP_SIGNING_KEY }} |
| 47 | + ORG_GRADLE_PROJECT_nexusPgpSigningPassword: ${{ secrets.NEXUS_PGP_SIGNING_PASSWORD }} |
| 48 | + run: | |
| 49 | + ./gradlew --info build -x test |
| 50 | + - name: Publish apt packages to Google Artifact Registry |
| 51 | + env: |
| 52 | + ORG_GRADLE_PROJECT_version: ${{ steps.release_info.outputs.RELEASE_VERSION }} |
| 53 | + ORG_GRADLE_PROJECT_artifactRegistryPublishEnabled: true |
| 54 | + GAR_JSON_KEY: ${{ secrets.GAR_JSON_KEY }} |
| 55 | + run: | |
| 56 | + ./gradlew --info publishDebToArtifactRegistry |
| 57 | + - name: Login to GAR |
| 58 | + # Only run this on repositories in the 'spinnaker' org, not on forks. |
| 59 | + if: startsWith(github.repository, 'spinnaker/') |
| 60 | + uses: docker/login-action@v1 |
| 61 | + # use service account flow defined at: https://github.com/docker/login-action#service-account-based-authentication-1 |
| 62 | + with: |
| 63 | + registry: us-docker.pkg.dev |
| 64 | + username: _json_key |
| 65 | + password: ${{ secrets.GAR_JSON_KEY }} |
| 66 | + - name: Build and publish slim container image |
| 67 | + # Only run this on repositories in the 'spinnaker' org, not on forks. |
| 68 | + if: startsWith(github.repository, 'spinnaker/') |
| 69 | + uses: docker/build-push-action@v2 |
| 70 | + with: |
| 71 | + context: . |
| 72 | + file: Dockerfile.slim |
| 73 | + push: true |
| 74 | + tags: | |
| 75 | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated" |
| 76 | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated-slim" |
| 77 | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-unvalidated-slim" |
| 78 | + - name: Build and publish ubuntu container image |
| 79 | + # Only run this on repositories in the 'spinnaker' org, not on forks. |
| 80 | + if: startsWith(github.repository, 'spinnaker/') |
| 81 | + uses: docker/build-push-action@v2 |
| 82 | + with: |
| 83 | + context: . |
| 84 | + file: Dockerfile.ubuntu |
| 85 | + push: true |
| 86 | + tags: | |
| 87 | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-unvalidated-ubuntu" |
| 88 | + "${{ env.CONTAINER_REGISTRY }}/${{ steps.build_variables.outputs.REPO }}:${{ steps.release_info.outputs.RELEASE_VERSION }}-${{ steps.build_variables.outputs.VERSION }}-unvalidated-ubuntu" |
| 89 | + - name: Create release |
| 90 | + if: steps.release_info.outputs.SKIP_RELEASE == 'false' |
| 91 | + uses: actions/create-release@v1 |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + with: |
| 95 | + tag_name: ${{ github.ref }} |
| 96 | + release_name: ${{ github.event.repository.name }} ${{ github.ref }} |
| 97 | + body: | |
| 98 | + ${{ steps.release_info.outputs.CHANGELOG }} |
| 99 | + draft: false |
| 100 | + prerelease: ${{ steps.release_info.outputs.IS_CANDIDATE }} |
0 commit comments