Skip to content

Commit f79691a

Browse files
authored
feat: 187 create mobilitydata maven packages (#190)
1 parent 30a0df2 commit f79691a

77 files changed

Lines changed: 737 additions & 268 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@ on:
33
pull_request:
44
branches:
55
- master
6-
push:
7-
branches:
8-
- master
6+
workflow_dispatch:
7+
8+
env:
9+
java_version: '17'
10+
java_distribution: 'zulu'
11+
912
jobs:
1013
maven-package:
1114
runs-on: ubuntu-24.04
1215
steps:
1316
- uses: actions/checkout@v5
1417
with:
1518
fetch-depth: 0
16-
- uses: actions/setup-java@v5
19+
- name: Set up JDK ${{ env.java_version }}-${{ env.java_distribution }}
20+
uses: actions/setup-java@v5
1721
with:
18-
java-version: 17.0.13
19-
distribution: liberica
22+
java-version: ${{ env.java_version }}
23+
distribution: ${{ env.java_distribution }}
24+
- name: Print Java and Maven versions
25+
run: mvn --version
2026
- name: Cache Maven dependencies
2127
uses: actions/cache@v4
2228
with:
@@ -27,7 +33,7 @@ jobs:
2733
${{ runner.os }}-maven-
2834
${{ runner.os }}-
2935
- name: Run maven build
30-
run: mvn verify -PprettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm
36+
run: mvn verify -PprettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm -ntp
3137
- name: codecov
3238
uses: codecov/codecov-action@v5
3339
with:
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Publish Snapshot
2+
# Required secrets / variables:
3+
#
4+
# Secrets are loaded from 1Password when both of the following are set:
5+
# - secrets.OP_SERVICE_ACCOUNT_TOKEN — 1Password service account token
6+
# - vars.ONE_PASSWORD_SECRET_REFERENCES — 1Password secret references for the variables below
7+
#
8+
# Without 1Password, set these GitHub repository secrets directly as a fallback:
9+
# - MAVEN_GPG_PRIVATE_KEY — armored GPG private key (used to sign artifacts)
10+
# - MAVEN_GPG_PASSPHRASE — passphrase for the GPG key
11+
# - MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME — Maven Central portal token username
12+
# - MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD — Maven Central portal token password
13+
14+
concurrency:
15+
group: deploy-master
16+
cancel-in-progress: false
17+
18+
on:
19+
push:
20+
branches:
21+
- master
22+
workflow_dispatch: # Manual trigger
23+
24+
env:
25+
java_version: '17'
26+
java_distribution: 'zulu'
27+
28+
jobs:
29+
publish-snapshot:
30+
if: "github.event_name == 'workflow_dispatch' || !contains(github.event.head_commit.message, 'ci skip')"
31+
runs-on: ubuntu-24.04
32+
env:
33+
HAS_1PASSWORD: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN != '' && vars.ONE_PASSWORD_SECRET_REFERENCES != '' }}
34+
steps:
35+
- uses: actions/checkout@v5
36+
with:
37+
fetch-depth: 0
38+
- name: Set up JDK ${{ env.java_version }}-${{ env.java_distribution }}
39+
uses: actions/setup-java@v5
40+
with:
41+
java-version: ${{ env.java_version }}
42+
distribution: ${{ env.java_distribution }}
43+
- name: Print Java and Maven versions
44+
run: mvn --version
45+
- name: Cache Maven dependencies
46+
uses: actions/cache@v4
47+
with:
48+
path: ~/.m2/repository
49+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
50+
restore-keys: |
51+
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
52+
${{ runner.os }}-maven-
53+
${{ runner.os }}-
54+
- name: Load secrets from 1Password
55+
if: env.HAS_1PASSWORD == 'true'
56+
# Pinned to a specific tag for supply-chain safety. Update the tag in gtfs-validator if the action changes.
57+
uses: MobilityData/gtfs-validator/.github/actions/extract-1password-secret@USED_BY_GBFS_VALIDATOR_JAVA # 7bf2832
58+
with:
59+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
60+
VARIABLES_TO_EXTRACT: 'MAVEN_GPG_PASSPHRASE, MAVEN_GPG_PRIVATE_KEY, MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME, MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD'
61+
ONE_PASSWORD_SECRET_REFERENCES: ${{ vars.ONE_PASSWORD_SECRET_REFERENCES }}
62+
- name: Load secrets from GitHub secrets (fallback for forks without 1Password)
63+
if: env.HAS_1PASSWORD != 'true'
64+
env:
65+
GPG_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
66+
GPG_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
67+
MVN_USER: ${{ secrets.MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME }}
68+
MVN_PASS: ${{ secrets.MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD }}
69+
run: |
70+
{
71+
echo "MAVEN_GPG_PASSPHRASE=$GPG_PASS"
72+
echo "MAVEN_GPG_PRIVATE_KEY<<GPG_EOF"
73+
echo "$GPG_KEY"
74+
echo "GPG_EOF"
75+
echo "MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME=$MVN_USER"
76+
echo "MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD=$MVN_PASS"
77+
} >> "$GITHUB_ENV"
78+
- name: Verify version is not placeholder
79+
run: |
80+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
81+
if [[ "$VERSION" == *"placeholder"* || "$VERSION" == "0.0.0"* ]]; then
82+
echo "ERROR: Version is still '$VERSION' — git-versioning extension failed to resolve. Aborting."
83+
exit 1
84+
fi
85+
echo "Version OK: $VERSION"
86+
- name: Stage artifacts
87+
run: mvn deploy -Ppublication -Dprettier.skip=true -ntp
88+
- name: Publish snapshot to Maven Central
89+
env:
90+
JRELEASER_GPG_PASSPHRASE: ${{ env.MAVEN_GPG_PASSPHRASE }}
91+
JRELEASER_GPG_SECRET_KEY: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
92+
# -N (non-recursive): run JReleaser only at the root so it uploads a single bundle.
93+
# Without it, JReleaser runs once per module and the second run fails with "already deployed".
94+
run: mvn jreleaser:deploy -Djreleaser.output.directory=out -ntp -N
95+
- name: Upload JReleaser output
96+
if: always()
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: jreleaser-snapshot-logs
100+
path: out/

.github/workflows/deploy.yml

Lines changed: 0 additions & 57 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Release
2+
# Required secrets / variables:
3+
#
4+
# Secrets are loaded from 1Password when both of the following are set:
5+
# - secrets.OP_SERVICE_ACCOUNT_TOKEN — 1Password service account token
6+
# - vars.ONE_PASSWORD_SECRET_REFERENCES — 1Password secret references for the variables below
7+
#
8+
# Without 1Password, set these GitHub repository secrets directly as a fallback:
9+
# - MAVEN_GPG_PRIVATE_KEY — armored GPG private key (used to sign artifacts)
10+
# - MAVEN_GPG_PASSPHRASE — passphrase for the GPG key
11+
# - MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME — Maven Central portal token username
12+
# - MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD — Maven Central portal token password
13+
14+
# Triggered when a GitHub release is published (released).
15+
# Builds, signs, and publishes all artifacts to Maven Central automatically.
16+
# The CLI fat jar is also uploaded to the GitHub release assets.
17+
#
18+
# The project version is derived from the git tag (e.g. v3.0.0 → 3.0.0) and applied to all
19+
# modules in-place via versions:set before building. No pom.xml version commits are needed.
20+
on:
21+
release:
22+
types: [released]
23+
24+
env:
25+
java_version: '17'
26+
java_distribution: 'zulu'
27+
28+
jobs:
29+
release:
30+
runs-on: ubuntu-24.04
31+
permissions:
32+
contents: write
33+
env:
34+
HAS_1PASSWORD: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN != '' && vars.ONE_PASSWORD_SECRET_REFERENCES != '' }}
35+
steps:
36+
- uses: actions/checkout@v5
37+
with:
38+
fetch-depth: 0
39+
# Check out the exact tagged commit so the version is correctly resolved from the tag.
40+
ref: ${{ github.event.release.tag_name }}
41+
- name: Set up JDK ${{ env.java_version }}-${{ env.java_distribution }}
42+
uses: actions/setup-java@v5
43+
with:
44+
java-version: ${{ env.java_version }}
45+
distribution: ${{ env.java_distribution }}
46+
- name: Print Java and Maven versions
47+
run: mvn --version
48+
- name: Cache Maven dependencies
49+
uses: actions/cache@v4
50+
with:
51+
path: ~/.m2/repository
52+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
53+
restore-keys: |
54+
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
55+
${{ runner.os }}-maven-
56+
${{ runner.os }}-
57+
- name: Load secrets from 1Password
58+
if: env.HAS_1PASSWORD == 'true'
59+
# Pinned to a specific tag for supply-chain safety. Update the tag in gtfs-validator if the action changes.
60+
uses: MobilityData/gtfs-validator/.github/actions/extract-1password-secret@USED_BY_GBFS_VALIDATOR_JAVA # 7bf2832
61+
with:
62+
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
63+
VARIABLES_TO_EXTRACT: 'MAVEN_GPG_PASSPHRASE, MAVEN_GPG_PRIVATE_KEY, MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME, MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD'
64+
ONE_PASSWORD_SECRET_REFERENCES: ${{ vars.ONE_PASSWORD_SECRET_REFERENCES }}
65+
- name: Load secrets from GitHub secrets (fallback for forks without 1Password)
66+
if: env.HAS_1PASSWORD != 'true'
67+
env:
68+
GPG_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
69+
GPG_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
70+
MVN_USER: ${{ secrets.MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME }}
71+
MVN_PASS: ${{ secrets.MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD }}
72+
run: |
73+
{
74+
echo "MAVEN_GPG_PASSPHRASE=$GPG_PASS"
75+
echo "MAVEN_GPG_PRIVATE_KEY<<GPG_EOF"
76+
echo "$GPG_KEY"
77+
echo "GPG_EOF"
78+
echo "MAVEN_CENTRAL_PORTAL_TOKEN_USERNAME=$MVN_USER"
79+
echo "MAVEN_CENTRAL_PORTAL_TOKEN_PASSWORD=$MVN_PASS"
80+
} >> "$GITHUB_ENV"
81+
- name: Set release version from tag
82+
run: |
83+
TAG="${{ github.event.release.tag_name }}"
84+
VERSION="${TAG#v}"
85+
echo "Setting version: $VERSION"
86+
mvn --batch-mode -ntp versions:set -DnewVersion="$VERSION" -DprocessAllModules=true -DgenerateBackupPoms=false
87+
- name: Verify version is not placeholder
88+
run: |
89+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
90+
if [[ "$VERSION" == *"placeholder"* || "$VERSION" == "0.0.0"* ]]; then
91+
echo "ERROR: Version is still '$VERSION' — aborting release."
92+
exit 1
93+
fi
94+
echo "Version OK: $VERSION"
95+
- name: Stage artifacts
96+
run: mvn deploy -Ppublication -Dprettier.skip=true -ntp
97+
- name: Upload CLI fat jar to GitHub release
98+
run: |
99+
gh release upload "${{ github.event.release.tag_name }}" \
100+
gbfs-validator-java-cli/target/gbfs-validator-cli.jar \
101+
--clobber
102+
env:
103+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
104+
- name: Deploy to Maven Central
105+
env:
106+
JRELEASER_GPG_PASSPHRASE: ${{ env.MAVEN_GPG_PASSPHRASE }}
107+
JRELEASER_GPG_SECRET_KEY: ${{ env.MAVEN_GPG_PRIVATE_KEY }}
108+
run: mvn jreleaser:deploy -Djreleaser.output.directory=out -ntp -N
109+
- name: Upload JReleaser output
110+
if: always()
111+
uses: actions/upload-artifact@v4
112+
with:
113+
name: jreleaser-release-logs
114+
path: out/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,7 @@ buildNumber.properties
1111
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
1212
.mvn/wrapper/maven-wrapper.jar
1313

14+
# Generated by maven-git-versioning-extension at build time — not to be committed
15+
.git-versioned-pom.xml
16+
1417
.vscode

.mvn/extensions.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 https://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
5+
<extension>
6+
<groupId>me.qoomon</groupId>
7+
<artifactId>maven-git-versioning-extension</artifactId>
8+
<version>9.11.0</version>
9+
</extension>
10+
</extensions>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration xmlns="https://github.com/qoomon/maven-git-versioning-extension"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="https://github.com/qoomon/maven-git-versioning-extension
5+
https://github.com/qoomon/maven-git-versioning-extension/raw/master/src/main/resources/configuration-schema.xsd">
6+
7+
<refs>
8+
<!-- Tagged commit: use the tag version directly (e.g. v2.0.67 → 2.0.67) -->
9+
<ref type="tag" pattern="v(?&lt;version&gt;.*)">
10+
<version>${version}</version>
11+
</ref>
12+
13+
<!-- master branch: increment patch and add SNAPSHOT (e.g. after v2.0.66 → 2.0.67-SNAPSHOT) -->
14+
<ref type="branch" pattern="master">
15+
<version>${describe.tag.version.major}.${describe.tag.version.minor}.${describe.tag.version.patch.next}-SNAPSHOT</version>
16+
</ref>
17+
18+
<!-- Any other branch: use branch name + SNAPSHOT for local development -->
19+
<ref type="branch" pattern=".*">
20+
<version>${describe.tag.version.major}.${describe.tag.version.minor}.${describe.tag.version.patch.next}-SNAPSHOT</version>
21+
</ref>
22+
</refs>
23+
</configuration>

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Validate GBFS feeds. Intended as Java native alternative to https://github.com/M
88

99
Uses the official json schema to validate files.
1010

11+
## Example
12+
13+
See the [`example/`](example/) directory for a working Maven project that depends on this library as a published artifact.
14+
1115
## Usage
1216

1317
Create an instance of `GbfsValidator`:

example/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target/
2+
.idea/
3+
*.iml

0 commit comments

Comments
 (0)