Skip to content

Commit 1c5744f

Browse files
committed
feat: deployment workflows
1 parent 7debc23 commit 1c5744f

4 files changed

Lines changed: 442 additions & 104 deletions

File tree

.github/changelog-config.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"categories": [
3+
{
4+
"title": "## Features",
5+
"labels": ["feature", "enhancement", "feat"]
6+
},
7+
{
8+
"title": "## Bug Fixes",
9+
"labels": ["bug", "fix", "bugfix"]
10+
},
11+
{
12+
"title": "## Maintenance",
13+
"labels": ["chore", "maintenance", "refactor", "deps", "dependencies"]
14+
},
15+
{
16+
"title": "## Documentation",
17+
"labels": ["docs", "documentation"]
18+
}
19+
],
20+
"ignore_labels": ["skip-changelog", "ignore"],
21+
"sort": {
22+
"order": "ASC",
23+
"on_property": "mergedAt"
24+
},
25+
"template": "#{{CHANGELOG}}\n\n**Full Changelog**: #{{RELEASE_DIFF}}",
26+
"pr_template": "- #{{TITLE}} (#{{NUMBER}})",
27+
"empty_template": "- No notable changes",
28+
"transformers": [
29+
{
30+
"pattern": "\\[.*?\\]\\s?",
31+
"target": ""
32+
}
33+
],
34+
"max_tags_to_fetch": 200,
35+
"max_pull_requests": 200,
36+
"max_back_track_time_days": 365,
37+
"exclude_merge_branches": ["master", "main"],
38+
"tag_resolver": {
39+
"method": "semver"
40+
}
41+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Java CI", "E2E Tests"]
6+
types: [completed]
7+
branches: [master]
8+
9+
permissions:
10+
contents: read
11+
actions: read
12+
13+
# Prevent duplicate publish attempts for the same commit
14+
concurrency:
15+
group: publish-${{ github.event.workflow_run.head_sha }}
16+
cancel-in-progress: false
17+
18+
jobs:
19+
publish:
20+
runs-on: ubuntu-latest
21+
# Only consider successful completions on master from push events
22+
if: >
23+
github.event.workflow_run.conclusion == 'success' &&
24+
github.event.workflow_run.head_branch == 'master' &&
25+
github.event.workflow_run.event == 'push'
26+
27+
steps:
28+
- name: Gate on Java CI + E2E success for same commit
29+
id: gate
30+
uses: actions/github-script@v7
31+
with:
32+
script: |
33+
const sha = context.payload.workflow_run.head_sha;
34+
console.log(`Checking workflow status for commit: ${sha}`);
35+
36+
async function getWorkflowStatus(workflowFile) {
37+
const runs = await github.rest.actions.listWorkflowRuns({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
workflow_id: workflowFile,
41+
head_sha: sha,
42+
per_page: 20,
43+
});
44+
45+
const anySuccess = runs.data.workflow_runs.some(r => r.conclusion === 'success');
46+
const anyInProgress = runs.data.workflow_runs.some(r => r.status !== 'completed');
47+
return { anySuccess, anyInProgress, count: runs.data.workflow_runs.length };
48+
}
49+
50+
const build = await getWorkflowStatus('build.yml');
51+
const e2e = await getWorkflowStatus('e2e.yml');
52+
53+
console.log(`Java CI: success=${build.anySuccess}, inProgress=${build.anyInProgress}, runs=${build.count}`);
54+
console.log(`E2E Tests: success=${e2e.anySuccess}, inProgress=${e2e.anyInProgress}, runs=${e2e.count}`);
55+
56+
if (!build.anySuccess || !e2e.anySuccess) {
57+
// Not ready yet - exit gracefully so the next workflow completion can trigger publish
58+
if (build.anyInProgress || e2e.anyInProgress) {
59+
core.notice(`Not publishing yet for ${sha} - workflows still in progress. buildSuccess=${build.anySuccess}, e2eSuccess=${e2e.anySuccess}`);
60+
} else {
61+
core.notice(`Not publishing for ${sha} - one or more workflows failed. buildSuccess=${build.anySuccess}, e2eSuccess=${e2e.anySuccess}`);
62+
}
63+
core.setOutput('ready', 'false');
64+
return;
65+
}
66+
67+
console.log(`Both workflows passed for ${sha} - proceeding with publish`);
68+
core.setOutput('ready', 'true');
69+
70+
- uses: actions/checkout@v4
71+
if: steps.gate.outputs.ready == 'true'
72+
with:
73+
# Checkout the exact commit that was tested, not latest master
74+
ref: ${{ github.event.workflow_run.head_sha }}
75+
76+
# Set up JDK 17 for Fabric 1.20.x builds (Gradle toolchain will use this)
77+
- name: Set up JDK 17
78+
if: steps.gate.outputs.ready == 'true'
79+
uses: actions/setup-java@v4
80+
with:
81+
java-version: 17
82+
distribution: "temurin"
83+
84+
# Set up JDK 21 as the primary JDK
85+
- name: Set up JDK 21
86+
if: steps.gate.outputs.ready == 'true'
87+
uses: actions/setup-java@v4
88+
with:
89+
java-version: 21
90+
distribution: "temurin"
91+
92+
- name: Setup Gradle
93+
if: steps.gate.outputs.ready == 'true'
94+
uses: gradle/actions/setup-gradle@v4
95+
with:
96+
cache-read-only: true
97+
98+
- name: Cache Loom
99+
if: steps.gate.outputs.ready == 'true'
100+
uses: actions/cache@v4
101+
with:
102+
path: |
103+
.gradle/loom-cache
104+
key: ${{ runner.os }}-loom-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}
105+
restore-keys: ${{ runner.os }}-loom-
106+
107+
- name: Publish to Maven Central
108+
if: steps.gate.outputs.ready == 'true'
109+
env:
110+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME }}
111+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPEPASSWORD }}
112+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEY }}
113+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGINMEMORYKEYPASSWORD }}
114+
run: |
115+
VERSION=$(grep "^version=" gradle.properties | cut -d'=' -f2)
116+
echo "Publishing version: $VERSION (commit: ${{ github.event.workflow_run.head_sha }})"
117+
if [[ "$VERSION" == *"SNAPSHOT"* ]]; then
118+
# SNAPSHOT: publish to Central Portal snapshot repository
119+
./gradlew publishToMavenCentral
120+
else
121+
# Release: publish and release to Maven Central
122+
./gradlew publishAndReleaseToMavenCentral
123+
fi

0 commit comments

Comments
 (0)