-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): Create a release from a tag instead of building off a re…
…lease publish event (#596)
- Loading branch information
Showing
5 changed files
with
91 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Fiat master | ||
name: master | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Fiat PR | ||
name: PR | ||
|
||
on: [pull_request] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"` |