Skip to content

Commit

Permalink
ci: replace jitpack with maven repo
Browse files Browse the repository at this point in the history
  • Loading branch information
darksaid98 committed May 28, 2024
1 parent 1975aae commit a03e9b0
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .github/actions/gradle/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: 'Setup Gradle'
description: 'Grant execute permissions and validate Gradle wrapper'

runs:
using: 'composite'
steps:
- name: Grant execute permissions for Gradle wrapper
run: chmod +x gradlew
shell: bash

- name: Validate Gradle Wrapper Authenticity
uses: gradle/actions/wrapper-validation@v3

- name: Setup Gradle and Caching
uses: gradle/actions/setup-gradle@v3
17 changes: 17 additions & 0 deletions .github/actions/jdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Setup JDK'
description: 'Set up JDK'

inputs:
java-version:
description: 'Java version'
required: true
default: '8'

runs:
using: 'composite'
steps:
- name: Setup JDK
uses: actions/setup-java@v4
with:
java-version: ${{ inputs.java-version }}
distribution: 'temurin'
98 changes: 98 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Release

on:
push:
branches:
- 'main'
- 'master'
workflow_dispatch:

permissions:
contents: write
discussions: write
pull-requests: write

jobs:
tests:
name: Run Tests
uses: ./.github/workflows/tests.yml
release:
name: Create Release
strategy:
matrix:
os: [ubuntu-latest]
java: [8]
runs-on: ${{ matrix.os }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
needs: [tests]
steps:
# Checkout repository
- name: Checkout Repository
uses: actions/checkout@v4

# Setup JDK
- name: Setup JDK
uses: ./.github/actions/jdk
with:
java-version: ${{ matrix.java }}

# Setup Gradle & Verify wrapper
- name: Setup Gradle
uses: ./.github/actions/gradle

# Makes the next semantic tag variable available for use in workflow
- uses: jveldboom/action-conventional-versioning@v1
id: version
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
default-bump: patch

# Build with Gradle & Publish to Maven repository
- name: Build with Gradle
run: ./gradlew clean build publish -PcustomVersion=${{ steps.version.outputs.version }}
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_NAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }}

# Generate changelog
- name: Changelog
uses: ardalanamini/auto-changelog@v4
id: changelog
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
commit-types: |
feat: New Features
fix: Bug Fixes
build: Build System & Dependencies
perf: Performance Improvements
docs: Documentation
test: Tests
refactor: Refactors
chore: Chores
ci: CI
style: Code Style
revert: Reverts
default-commit-type: Other Changes
release-name: ${{ steps.version.outputs.version-with-prefix }}
mention-authors: true
mention-new-contributors: true
include-compare-link: true
include-pr-links: true
include-commit-links: true
semver: true
use-github-autolink: true

# Create release
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
${{ github.workspace }}/build/libs/*
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ steps.version.outputs.version-with-prefix }}
draft: false
prerelease: ${{ contains(github.ref_name, '-RC-') }}
generate_release_notes: false
body: ${{ steps.changelog.outputs.changelog }}
56 changes: 56 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Run Tests

on:
push:
branches-ignore: # Tests are triggered from release workflow
- 'main'
- 'master'
workflow_dispatch:
workflow_call:

permissions:
contents: write
discussions: write
pull-requests: write

jobs:
test-build:
name: Test Build
strategy:
matrix:
os: [ubuntu-latest]
java: [8]
runs-on: ${{ matrix.os }}
steps:
# Checkout repository
- name: Checkout Repository
uses: actions/checkout@v4

# Setup JDK
- name: Setup JDK
uses: ./.github/actions/jdk
with:
java-version: ${{ matrix.java }}

# Setup Gradle & Verify wrapper
- name: Setup Gradle
uses: ./.github/actions/gradle

# Makes the next semantic tag variable available for use in workflow
- uses: jveldboom/action-conventional-versioning@v1
id: version
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
default-bump: patch

# Build with Gradle
- name: Build with Gradle
run: ./gradlew clean build -PcustomVersion=${{ steps.version.outputs.version }}-SNAPSHOT-${{ github.run_number }} --info

# Upload build results
- name: Upload build results
uses: actions/upload-artifact@v4
with:
name: Build ${{ steps.version.outputs.version-with-prefix }}-SNAPSHOT-${{ github.run_number }}
path: ${{ github.workspace }}/build/libs/
retention-days: 3
50 changes: 50 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.time.Instant

plugins {
`java-library`
`maven-publish`
Expand Down Expand Up @@ -65,14 +67,62 @@ tasks {
}
}

// Apply custom version arg
val versionArg = if (hasProperty("customVersion"))
(properties["customVersion"] as String).uppercase() // Uppercase version string
else
"${project.version}-SNAPSHOT-${Instant.now().epochSecond}" // Append snapshot to version

// Strip prefixed "v" from version tag
project.version = if (versionArg.first().equals('v', true))
versionArg.substring(1)
else
versionArg.uppercase()

publishing {
publications {
create<MavenPublication>("maven") {
groupId = "${project.group}"
artifactId = "colorparser"
version = "${project.version}"

pom {
name.set("ColorParser")
description.set(rootProject.description.orEmpty())
url.set("https://github.com/milkdrinkers/ColorParser")
licenses {
license {
name.set("GNU General Public License version 3")
url.set("https://opensource.org/license/gpl-3-0/")
}
}
developers {
developer {
id.set("darksaid98")
name.set("darksaid98")
organization.set("Milkdrinkers")
organizationUrl.set("https://github.com/milkdrinkers")
}
}
scm {
connection.set("scm:git:git://github.com/milkdrinkers/ColorParser.git")
developerConnection.set("scm:git:ssh://github.com:milkdrinkers/ColorParser.git")
url.set("https://github.com/milkdrinkers/ColorParser")
}
}

from(components["java"])
}
}

repositories {
maven {
name = "milkdrinkers"
url = uri("https://maven.athyrium.eu/releases")
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
2 changes: 0 additions & 2 deletions jitpack.yml

This file was deleted.

0 comments on commit a03e9b0

Please sign in to comment.