Skip to content

Publish and Release acidify-core to Maven Central #40

Publish and Release acidify-core to Maven Central

Publish and Release acidify-core to Maven Central #40

name: Publish and Release acidify-core to Maven Central
on:
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
publish:
name: Release build and publish
runs-on: macos-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Extract release metadata
id: release
shell: bash
run: |
VERSION="$(sed -nE 's/^[[:space:]]*version[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' acidify-core/build.gradle.kts | head -n1)"
if [[ -z "$VERSION" ]]; then
echo "Cannot find version in acidify-core/build.gradle.kts" >&2
exit 1
fi
TAG="v${VERSION}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "Resolved release version: ${VERSION} (${TAG})"
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 25
- name: Generate JS Production Build
run: ./gradlew :acidify-core:jsNodeProductionLibraryDistribution
- name: Publish to MavenCentral
run: ./gradlew :acidify-core:publishAndReleaseToMavenCentral
env:
GITHUB_ACTIONS_BUILD_CORE_LIBRARY: 'true'
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_KEY_CONTENTS }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ''
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
package_json_file: acidify-core-js/package.json
run_install: false
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'pnpm'
cache-dependency-path: acidify-core-js/pnpm-lock.yaml
registry-url: https://registry.npmjs.org
- name: Ensure npm is up to date
run: pnpm install -g npm@latest
- name: Install npm dependencies
run: |
cd acidify-core-js
pnpm install
- name: Sync npm package version
run: |
python3 <<'PY'
import json
from pathlib import Path
version = "${{ steps.release.outputs.version }}"
package_json = Path("acidify-core-js/package.json")
data = json.loads(package_json.read_text(encoding="utf-8"))
data["version"] = version
package_json.write_text(json.dumps(data, indent=2) + "\n", encoding="utf-8")
print(f"Set npm package version to {version}")
PY
- name: Publish @acidify/core to npm
run: |
cd acidify-core-js
npm publish --access public
- name: Create and push Git tag
shell: bash
run: |
TAG="${{ steps.release.outputs.tag }}"
if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then
echo "Tag ${TAG} already exists on remote." >&2
exit 1
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag "${TAG}"
git push origin "${TAG}"
- name: Create GitHub release draft
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release.outputs.tag }}
name: acidify-core ${{ steps.release.outputs.version }}
draft: true
generate_release_notes: false
body: |
Maven Central: `org.ntqqrev:acidify-core:${{ steps.release.outputs.version }}`
npm: `@acidify/core@${{ steps.release.outputs.version }}`
(Release Notes Here)
> 在寻找 Yogurt?请查看 https://acidify.ntqqrev.org/yogurt/start