Skip to content

Commit

Permalink
Enable GitHub Actions builds (#1)
Browse files Browse the repository at this point in the history
* Enable GitHub Actions builds

* Control version from CI

* Automatic GitHub releases

* Set task names

* Fix tag pattern

* Change default version to 1.0
  • Loading branch information
turikhay authored Aug 22, 2023
1 parent 2fba55d commit 9e4ee6c
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build

on:
push:
branches:
- '**'
tags-ignore:
- 'v*.*'
workflow_call:
inputs:
version:
type: string

jobs:
build:
name: Gradle build
runs-on: ubuntu-latest
steps:
- id: version
name: Detect version
run: echo "version=${VERSION:-1.0+git-${GITHUB_SHA::7}}" >> $GITHUB_OUTPUT
env:
VERSION: ${{ inputs.version }}
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: |
build
-Pversion=${{ steps.version.outputs.version }}
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: gradle-build
path: build/libs/*-all.jar
47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: GitHub release

on:
push:
tags:
- 'v*.*'

permissions:
contents: write

jobs:
version:
name: Extract version from git
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- id: version
name: Extract version
run: |
TAG=${{ github.ref }}
VERSION=${TAG#refs/tags/v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
build:
name: Build
needs: version
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.version.outputs.version }}
release:
name: Prepare release
needs:
- version
- build
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: gradle-build
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
name: ${{ needs.version.outputs.version }}
generate_release_notes: true
draft: true
files: '*'
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ plugins {
}

group = "info.mmpa"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Default development version
# See: ./.github/workflows/build.yml
version=1.0-SNAPSHOT

0 comments on commit 9e4ee6c

Please sign in to comment.