Skip to content

Commit

Permalink
chore(ci/cd): publish to central
Browse files Browse the repository at this point in the history
  • Loading branch information
xooooooooox committed Dec 27, 2024
1 parent 0ab17be commit ad6a745
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 39 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish-github-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish package to GitHub Packages

on:
push:
branches:
- main
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'

- name: Publish to GitHub Packages
run: |
./mvnw --batch-mode clean deploy \
-DaltDeploymentRepository=github::https://maven.pkg.github.com/xooooooooox/radp -DskipTests \
-DskipTests
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
37 changes: 0 additions & 37 deletions .github/workflows/trigger-publish-packages.yml

This file was deleted.

57 changes: 57 additions & 0 deletions .github/workflows/trigger-releases.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish to Maven Central and GitHub Packages

on:
push:
branches:
- feat/241227-v0.4
release:
types: [created] # triggers on release creation
workflow_dispatch: # allows manual trigger if you wish

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Check out code
uses: actions/checkout@v4

# - name: Validate tag version format
# run: |
# # Fail if the release tag doesn't match x.x.x
# if [[ ! "${{ github.event.release.tag_name }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# echo "::error ::Invalid version format '${{ github.event.release.tag_name }}'. Must match x.x.x."
# exit 1
# fi

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
server-id: central-portal
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
# import gpg
gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: List keys
run: gpg -K

# - name: Set version
# run: |
# gpg -K
# mvn versions:set -DnewVersion=${{ github.event.release.tag_name }}
#
# - name: Publish package
# run: |
# ./mvnw --batch-mode clean deploy \
# -Pcoding,publish-central -DskipTests
# env:
# MAVEN_USERNAME: ${{ secrets.CENTRAL_TOKEN_USERNAME }}
# MAVEN_PASSWORD: ${{ secrets.CENTRAL_TOKEN_PASSWORD }}
# MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<tagNameFormat>@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<allowReleasePluginSnapshot>true</allowReleasePluginSnapshot>
<!-- 如果为true, 那么 performRelease 将会为 true -->
Expand Down
2 changes: 1 addition & 1 deletion radp-components/radp-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<tagNameFormat>@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<allowReleasePluginSnapshot>true</allowReleasePluginSnapshot>
<!-- 如果为true, 那么 performRelease 将会为 true -->
Expand Down

0 comments on commit ad6a745

Please sign in to comment.