Skip to content

Commit ba400b4

Browse files
committed
chore: add github action workflow for build and publish
1 parent 6e01386 commit ba400b4

File tree

6 files changed

+292
-2
lines changed

6 files changed

+292
-2
lines changed

.github/dependabot.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gradle"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 5
8+
labels:
9+
- "gradle"
10+
- "dependencies"
11+
reviewers:
12+
- sureshg
13+
14+
- package-ecosystem: "gradle"
15+
directory: "/gradle/build-logic"
16+
schedule:
17+
interval: "daily"
18+
open-pull-requests-limit: 5
19+
labels:
20+
- "gradle"
21+
- "dependencies"
22+
reviewers:
23+
- sureshg
24+
25+
- package-ecosystem: "github-actions"
26+
directory: "/"
27+
schedule:
28+
interval: "daily"
29+
open-pull-requests-limit: 5
30+
labels:
31+
- "github-actions"
32+
- "dependencies"
33+
reviewers:
34+
- sureshg
35+
36+
- package-ecosystem: "docker"
37+
directory: "/"
38+
schedule:
39+
interval: "daily"
40+
labels:
41+
- "docker"
42+
- "dependencies"

.github/release.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
- ci
6+
- skip-ci
7+
authors:
8+
- octocat
9+
categories:
10+
- title: New Features 🎉
11+
labels:
12+
- feat
13+
- enhancement
14+
- title: Breaking Changes 🛠
15+
labels:
16+
- Semver-Major
17+
- breaking-change
18+
- title: Fixes 🐛
19+
labels:
20+
- fix
21+
- bug
22+
- title: Maintenance 🧰
23+
labels:
24+
- chore
25+
- maintenance
26+
- title: Tests 🧪
27+
labels:
28+
- test
29+
- title: Documentation 🖍️
30+
labels:
31+
- doc
32+
- title: Dependencies 📦️
33+
labels:
34+
- deps
35+
- dependencies
36+
- chore(deps)
37+
- build(deps)
38+
- title: Other Changes 🖇️
39+
labels:
40+
- "*"

.github/workflows/build.yml

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- '*'
9+
paths-ignore:
10+
- LICENSE
11+
- '*.md'
12+
- 'docs/**'
13+
- '.github/config/labels.yml'
14+
15+
pull_request:
16+
branches:
17+
- main
18+
19+
schedule:
20+
- cron: "0 0 * * *"
21+
22+
workflow_dispatch:
23+
24+
defaults:
25+
run:
26+
shell: bash
27+
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ github.ref }}
30+
cancel-in-progress: true
31+
32+
permissions:
33+
contents: write
34+
issues: write
35+
packages: write
36+
repository-projects: write
37+
38+
env:
39+
releaseBuild: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }}
40+
41+
jobs:
42+
build:
43+
name: 🏗️ Gradle Build
44+
strategy:
45+
fail-fast: true
46+
matrix:
47+
os: [ ubuntu-latest ]
48+
distribution: [ zulu ]
49+
java: [ 21 ]
50+
51+
runs-on: ${{ matrix.os }}
52+
continue-on-error: false
53+
54+
steps:
55+
- name: 🛎️ Check out the source code
56+
uses: actions/checkout@v4
57+
with:
58+
fetch-depth: 0
59+
60+
- name: ☕ Install ${{ matrix.distribution }} JDK ${{ matrix.jdk }}
61+
id: install-java
62+
uses: actions/setup-java@v4
63+
with:
64+
distribution: ${{ matrix.distribution }}
65+
java-version: ${{ matrix.java }}
66+
check-latest: true
67+
# cache: 'gradle'
68+
69+
- name: 🐘 Setup Gradle
70+
uses: gradle/actions/setup-gradle@v4
71+
72+
- name: 🏗️ Gradle Build
73+
id: gradle-build
74+
run: |
75+
./gradlew build --no-daemon
76+
77+
- name: 📦 Upload Plugin artifact
78+
if: steps.gradle-build.outcome == 'success'
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: plugin-jar
82+
path: catalog/build/libs/plugins-*.jar
83+
if-no-files-found: error
84+
85+
- name: 📄 Upload Version Catalog
86+
if: steps.gradle-build.outcome == 'success'
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: version-catalog
90+
path: plugins/build/version-catalog/libs.versions.toml
91+
if-no-files-found: error
92+
93+
release:
94+
name: 🚰 Release new version.
95+
needs: [ build ]
96+
if: startsWith(github.ref, 'refs/tags/') && needs.build.result == 'success' && github.repository == 'sureshg/build-commons'
97+
runs-on: ubuntu-latest
98+
99+
steps:
100+
- name: 🛎️Check out the source code
101+
uses: actions/checkout@v4
102+
with:
103+
fetch-depth: 0
104+
submodules: recursive
105+
106+
- name: ☕ Install Zulu JDK 21
107+
id: install-java
108+
uses: actions/setup-java@v4
109+
with:
110+
distribution: zulu
111+
java-version: 21
112+
check-latest: true
113+
114+
- name: 🐘 Setup Gradle
115+
uses: gradle/actions/setup-gradle@v4
116+
117+
- name: ⚙️Build Changelog
118+
id: github_release
119+
uses: mikepenz/release-changelog-builder-action@v5
120+
with:
121+
configuration: ".github/config/configuration.json"
122+
commitMode: true
123+
ignorePreReleases: ${{ !contains(github.ref, '-') }}
124+
env:
125+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126+
127+
- name: 📡Publish to Maven Central
128+
id: gradle-build
129+
run: |
130+
./gradlew publishPluginMavenPublicationToMavenCentralRepository
131+
./gradlew :catalog:publishToMavenCentral
132+
env:
133+
GITHUB_USER: ${{ github.repository_owner }}
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
136+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
137+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_PRIVATE_KEY_ID }}
138+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_PRIVATE_KEY }}
139+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PRIVATE_KEY_PASSWORD }}
140+
ORG_GRADLE_PROJECT_githubActor: ${{ github.actor }}
141+
ORG_GRADLE_PROJECT_githubToken: ${{ secrets.GITHUB_TOKEN }}
142+
143+
- name: ✨Github Release
144+
uses: softprops/action-gh-release@v2
145+
with:
146+
body: ${{ steps.github_release.outputs.changelog }}
147+
files: |
148+
${{ github.workspace }}/catalog/build/libs/plugins-*.jar
149+
${{ github.workspace }}/plugins/build/version-catalog/libs.versions.toml
150+
generate_release_notes: true
151+
fail_on_unmatched_files: true
152+
env:
153+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/dependabot-prs.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Dependabot auto-approve
2+
3+
on: pull_request_target
4+
5+
permissions: write-all
6+
7+
jobs:
8+
dependabot:
9+
runs-on: ubuntu-latest
10+
if: github.actor == 'dependabot[bot]'
11+
steps:
12+
- name: 🔧Dependabot metadata
13+
id: dependabot-metadata
14+
uses: dependabot/fetch-metadata@v2.2.0
15+
with:
16+
github-token: "${{ secrets.GITHUB_TOKEN }}"
17+
18+
- name: Approve a PR
19+
run: gh pr review --approve "$PR_URL"
20+
env:
21+
PR_URL: ${{github.event.pull_request.html_url}}
22+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
23+
24+
- name: Enable auto-merge for Dependabot PRs
25+
if: steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major'
26+
run: gh pr merge --auto --merge "$PR_URL"
27+
env:
28+
PR_URL: ${{github.event.pull_request.html_url}}
29+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
30+
31+
- name: Add a label for dependencies
32+
if: steps.dependabot-metadata.outputs.dependency-type == 'direct:production'
33+
run: gh pr edit "$PR_URL" --add-label "dependencies"
34+
env:
35+
PR_URL: ${{github.event.pull_request.html_url}}
36+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.github/workflows/sync-labels.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Sync labels
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- .github/config/labels.yml
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: micnncim/action-label-syncer@v1
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
with:
19+
manifest: .github/config/labels.yml

buildSrc/src/main/kotlin/plugins/publishing.gradle.kts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import kotlin.text.lowercase
66
import libs
77

88
plugins {
9+
id("com.javiersc.semver")
910
// https://github.com/vanniktech/gradle-maven-publish-plugin/issues/846
10-
id("org.gradle.kotlin.kotlin-dsl")
11+
// id("org.gradle.kotlin.kotlin-dsl")
1112
id("com.vanniktech.maven.publish")
12-
id("com.javiersc.semver")
1313
}
1414

1515
group = libs.versions.group.get()

0 commit comments

Comments
 (0)