Skip to content

Commit

Permalink
Merge pull request #34 from blast-hardcheese/auto-tag-version
Browse files Browse the repository at this point in the history
Copy over auto-tagging functionality from sbt-guardrail
  • Loading branch information
blast-hardcheese authored Dec 26, 2020
2 parents dcf5595 + 20d9957 commit ef48fef
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name-template: 'v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'bug'
- title: '🧰 Maintenance'
label: 'chore'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
template: |
## Changes
$CHANGES
## Contributors
Thanks to $CONTRIBUTORS for your contributions to this release!
45 changes: 45 additions & 0 deletions .github/workflows/tag-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Tag release

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ '8' ]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: print Java version
run: java -version
- uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Guess next version based on the library version
id: guessversion
run: |
source scripts/next-version.sh
echo "::set-output name=exists::${exists}"
echo "VERSION=${version}" >> $GITHUB_ENV
- name: Publish release notes
if: steps.guessversion.outputs.exists == 0
uses: release-drafter/release-drafter@v5
with:
publish: true
name: "v${{ env.VERSION }}"
tag: "v${{ env.VERSION }}"
version: "v${{ env.VERSION }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions scripts/next-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# next-version.sh
# Guess the next version of the sbt-guardrail plugin based on the current library dependency
# Ideally, this'll let actions automatically tag and release.
#
# Strategy is to pull the com.twilio %% guardrail % <VERSION>,
# ... check to see if a tag with that version exists,
# ... if so, exit 1
# ... if not, emit that version to stdout

# Extract library version
version="$(grep -ho 'com.twilio:guardrail_2.12:[^"]*"' build.gradle | grep -ho '\<\([0-9]\+\)\(\.[0-9]\+\)\{1,\}')"

exists=0
# Check to see if we've already released for this library version
if git rev-parse "v${version}" >/dev/null 2>&1; then
exists=1
fi

0 comments on commit ef48fef

Please sign in to comment.