Skip to content

Commit 614c555

Browse files
committed
Workflows
1 parent d2a440f commit 614c555

File tree

5 files changed

+222
-0
lines changed

5 files changed

+222
-0
lines changed

.github/settings.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
5+
https://maven.apache.org/xsd/settings-1.0.0.xsd">
6+
<servers>
7+
<server>
8+
<id>github</id>
9+
<username>${env.MAVEN_USERNAME}</username>
10+
<password>${env.MAVEN_PASSWORD}</password>
11+
</server>
12+
</servers>
13+
</settings>

.github/workflows/codeql.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '32 6 * * 2'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze Java
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Initialize CodeQL
23+
uses: github/codeql-action/init@v3
24+
with:
25+
languages: java
26+
27+
- name: Set up JDK 8
28+
uses: actions/setup-java@v4
29+
with:
30+
java-version: '8'
31+
distribution: 'temurin'
32+
cache: maven
33+
34+
- name: Autobuild
35+
uses: github/codeql-action/autobuild@v3
36+
37+
- name: Perform CodeQL Analysis
38+
uses: github/codeql-action/analyze@v3
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
branches:
8+
- 'feature/release-*'
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '8'
23+
distribution: 'temurin'
24+
cache: maven
25+
26+
- name: Setup GPG
27+
run: |
28+
echo "Setting up GPG..."
29+
mkdir -p ~/.gnupg
30+
chmod 700 ~/.gnupg
31+
32+
echo "${{ secrets.GPG_PRIVATE_KEY }}" > private.key
33+
echo "Importing GPG key..."
34+
gpg --batch --import private.key
35+
rm private.key
36+
37+
echo "Configuring GPG..."
38+
cat > ~/.gnupg/gpg.conf << EOF
39+
default-key ${{ secrets.GPG_KEYNAME }}
40+
use-agent
41+
pinentry-mode loopback
42+
EOF
43+
44+
echo "=== GPG Keys ==="
45+
gpg --list-secret-keys --keyid-format LONG
46+
gpg --list-keys --keyid-format LONG
47+
48+
- name: Configure Maven
49+
run: |
50+
mkdir -p ~/.m2
51+
cat > ~/.m2/settings.xml << EOF
52+
<settings>
53+
<servers>
54+
<server>
55+
<id>central</id>
56+
<username>${{ secrets.OSSRH_USERNAME_TOKEN }}</username>
57+
<password>${{ secrets.OSSRH_PASSWORD_TOKEN }}</password>
58+
</server>
59+
</servers>
60+
<profiles>
61+
<profile>
62+
<id>central</id>
63+
<activation>
64+
<activeByDefault>true</activeByDefault>
65+
</activation>
66+
<properties>
67+
<gpg.executable>gpg</gpg.executable>
68+
<gpg.passphrase>${{ secrets.GPG_PASSPHRASE }}</gpg.passphrase>
69+
</properties>
70+
</profile>
71+
</profiles>
72+
</settings>
73+
EOF
74+
75+
- name: Build and Publish
76+
env:
77+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME_TOKEN }}
78+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD_TOKEN }}
79+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
80+
run: |
81+
echo "Starting Maven build and deploy..."
82+
mvn clean deploy -P release \
83+
-Dmaven.javadoc.skip=false \
84+
-Dmaven.deploy.skip=false \
85+
-Dgpg.keyname=${{ secrets.GPG_KEYNAME }} \
86+
-Dgpg.useagent=true \
87+
-Dmaven.test.failure.ignore=false \
88+
-DaltDeploymentRepository=ossrh::default::https://central.sonatype.com/api/v1/publisher/upload \
89+
-DrepositoryId=ossrh \
90+
-Dusername=${{ secrets.OSSRH_USERNAME_TOKEN }} \
91+
-Dpassword=${{ secrets.OSSRH_PASSWORD_TOKEN }}

.github/workflows/maven.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build and Publish
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches: [ main ]
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
packages: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up JDK 8
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: '8'
23+
distribution: 'temurin'
24+
- name: Build
25+
run: mvn clean install -Dmaven.javadoc.skip=true
26+
- name: Create Release
27+
if: startsWith(github.ref, 'refs/tags/')
28+
uses: softprops/action-gh-release@v1
29+
with:
30+
files: |
31+
target/*.jar
32+
target/*.pom
33+
target/*.asc
34+
target/*.md5
35+
target/*.sha1
36+
generate_release_notes: true
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up JDK 8
19+
uses: actions/setup-java@v4
20+
with:
21+
java-version: '8'
22+
distribution: 'temurin'
23+
cache: 'maven'
24+
25+
- name: Build with Maven
26+
run: |
27+
mvn -B clean package -DskipTests
28+
mvn -B javadoc:javadoc
29+
mvn -B source:jar
30+
31+
- name: Create Release
32+
uses: softprops/action-gh-release@v1
33+
with:
34+
name: Release ${{ github.ref_name }}
35+
draft: false
36+
prerelease: false
37+
generate_release_notes: true
38+
files: |
39+
target/wordpress-api-client-*.jar
40+
target/site/apidocs/**
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)