Skip to content

Commit

Permalink
Merge pull request #3 from PabloDons/master
Browse files Browse the repository at this point in the history
workflow to automatically tag commits with version
  • Loading branch information
paulikauro authored May 19, 2021
2 parents ca724c7 + dcc3ce0 commit f603f40
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Release

on:
workflow_dispatch:
push:
branches: [ $default-branch ]
tags:
- 'v*'
branches: [ master ]

jobs:
build:
Expand All @@ -24,20 +23,27 @@ jobs:
- name: Build and test
run: ./gradlew build

- name: Tag name and copy jar
id: names
run: |
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
cp build/libs/RedstoneTools*.jar asset.jar
- name: Get version
id: version
run: echo ::set-output name=version::v$(./gradlew -q getVersion).${{ github.run_number }}

- name: Push new tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CUSTOM_TAG: ${{ steps.version.outputs.version }}

- name: Copy jar
run: cp build/libs/RedstoneTools*.jar asset.jar

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: ${{ steps.names.outputs.tag }}
tag_name: ${{ steps.version.outputs.version }}
release_name: ${{ steps.version.outputs.version }}
draft: false
prerelease: false

Expand All @@ -48,5 +54,5 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: asset.jar
asset_name: RedstoneTools-${{ steps.names.outputs.tag }}.jar
asset_name: RedstoneTools-${{ steps.version.outputs.version }}.jar
asset_content_type: application/java-archive
12 changes: 4 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.ByteArrayOutputStream

group = ""
version = execute("git", "describe", "--long", "--dirty")
version = "1.2"

plugins {
val kotlinVersion = "1.4.21"
Expand Down Expand Up @@ -67,11 +67,7 @@ tasks.build {
dependsOn(tasks.shadowJar)
}

tasks.register("getVersion") {
println(version)
}

fun execute(vararg command: String): String = ByteArrayOutputStream()
.also { output ->
project.exec {
commandLine = command.toList()
standardOutput = output
}
}.toString().trim()

0 comments on commit f603f40

Please sign in to comment.