diff --git a/.github/workflows/candidate.yml b/.github/workflows/candidate.yml new file mode 100644 index 000000000..8d42436df --- /dev/null +++ b/.github/workflows/candidate.yml @@ -0,0 +1,48 @@ +name: Candidate release + +on: + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-java@v1 + with: + java-version: 8 + - uses: actions/cache@v1 + with: + path: ~/.gradle + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Candidate build + env: + BINTRAY_USER: ${{ secrets.BINTRAY_USER }} + BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} + GRADLE_OPTS: -Xmx6g -Xms6g -Dorg.gradle.daemon=false + run: | + ./gradlew -PenablePublishing=true --info -Prelease.disableGitChecks=true -Prelease.useLastTag=true -PbintrayUser="${BINTRAY_USER}" -PbintrayKey="${BINTRAY_API_KEY}" candidate + - name: Get the changelog + id: get_changelog + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + . .github/workflows/release_info.sh ${{ github.event.repository.name }} + echo ::set-output name=CHANGELOG::$(echo -e "${CHANGELOG}") + echo ::set-output name=SKIP_RELEASE::${SKIP_RELEASE} + - name: Create release + if: steps.get_changelog.outputs.SKIP_RELEASE == 'false' + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.event.repository.name }} ${{ github.ref }} + body: | + ${{ steps.get_changelog.outputs.CHANGELOG }} + draft: false + prerelease: true \ No newline at end of file diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index e4dad6aa7..ff67b5ae0 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -1,4 +1,4 @@ -name: Fiat master +name: master on: push: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index fe4589dd7..fda3eee73 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,4 @@ -name: Fiat PR +name: PR on: [pull_request] diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b9ade5c04..b24681ab5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,8 +1,9 @@ -name: Fiat release +name: Release on: - release: - types: [published] + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" jobs: build: @@ -18,22 +19,33 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} restore-keys: | ${{ runner.os }}-gradle- - - name: Candidate build - env: - BINTRAY_USER: ${{ secrets.BINTRAY_USER }} - BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} - GRADLE_OPTS: -Xmx6g -Xms6g -Dorg.gradle.daemon=false - if: github.event.release.prerelease == true && startsWith(github.event.ref, 'version-') != true # skip tags that start with 'version-' - run: | - ./gradlew -PenablePublishing=true --info -Prelease.disableGitChecks=true -Prelease.useLastTag=true -PbintrayUser="${BINTRAY_USER}" -PbintrayKey="${BINTRAY_API_KEY}" candidate - name: Release build env: BINTRAY_USER: ${{ secrets.BINTRAY_USER }} BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} SPINNAKER_GITHUB_TOKEN: ${{ secrets.SPINNAKER_GITHUB_TOKEN }} GRADLE_OPTS: -Xmx6g -Xms6g -Dorg.gradle.daemon=false - if: github.event.release.prerelease != true && startsWith(github.event.ref, 'version-') != true # skip tags that start with 'version-' run: | ./gradlew -PenablePublishing=true --info -Prelease.disableGitChecks=true -Prelease.useLastTag=true -PbintrayUser="${BINTRAY_USER}" -PbintrayKey="${BINTRAY_API_KEY}" final sleep 90 ./gradlew -PenablePublishing=true --info -Prelease.disableGitChecks=true -Prelease.useLastTag=true -PbintrayUser="${BINTRAY_USER}" -PbintrayKey="${BINTRAY_API_KEY}" -Pgithub.token="${SPINNAKER_GITHUB_TOKEN}" bumpDependencies + - name: Get the changelog + id: get_changelog + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + . .github/workflows/release_info.sh ${{ github.event.repository.name }} + echo ::set-output name=CHANGELOG::$(echo -e "${CHANGELOG}") + echo ::set-output name=SKIP_RELEASE::${SKIP_RELEASE} + - name: Create release + if: steps.get_changelog.outputs.SKIP_RELEASE == 'false' + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.event.repository.name }} ${{ github.ref }} + body: | + ${{ steps.get_changelog.outputs.CHANGELOG }} + draft: false + prerelease: false diff --git a/.github/workflows/release_info.sh b/.github/workflows/release_info.sh new file mode 100755 index 000000000..fa4817fcc --- /dev/null +++ b/.github/workflows/release_info.sh @@ -0,0 +1,17 @@ +#!/bin/bash -x + +# 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/jonsie/$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` +echo "CHANGELOG=$CHANGELOG" + +#Format the changelog so it's markdown compatible +CHANGELOG="${CHANGELOG//$'%'/%25}" +CHANGELOG="${CHANGELOG//$'\n'/%0A}" +CHANGELOG="${CHANGELOG//$'\r'/%0D}" + +# If the previous release tag is the same as this tag the user likely cut a release (and in the process created a tag), which means we can skip the need to create a release +export SKIP_RELEASE=`[[ "$PREVIOUS_TAG" = "$NEW_TAG" ]] && echo "true" || echo "false"`