-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (101 loc) · 4.25 KB
/
publish.yml
File metadata and controls
118 lines (101 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Publish
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-*"
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
jobs:
publish:
name: Publish to Maven Central
runs-on: ubuntu-latest
environment: Main
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-build-env
- name: Determine version
id: version
run: |
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
# Release: strip the leading "v" from the tag (e.g. v1.0.0 -> 1.0.0)
VERSION="${GITHUB_REF_NAME#v}"
else
# SNAPSHOT: read baseline from gradle.properties and append -SNAPSHOT
BASE=$(grep "^VERSION_NAME=" gradle.properties | cut -d= -f2 | sed 's/-SNAPSHOT//')
VERSION="${BASE}-SNAPSHOT"
fi
echo "VERSION_NAME=${VERSION}" | tee -a "$GITHUB_OUTPUT"
- name: Publish to Maven Central
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_KEY_ID }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_KEY_PASSWORD }}
ORG_GRADLE_PROJECT_VERSION_NAME: ${{ steps.version.outputs.VERSION_NAME }}
# publishToMavenCentral = manual promotion (no auto-release); --no-configuration-cache for
# release-pipeline debuggability (runs once per tag, CC savings are zero).
run: ./gradlew --no-daemon publishToMavenCentral --no-configuration-cache
publish-xcframework:
name: Publish XCFramework to GitHub Release
# Only runs for version tags — not for SNAPSHOT pushes to main.
if: startsWith(github.ref, 'refs/tags/')
runs-on: macos-latest
permissions:
contents: write # Required to upload release assets and update Package.swift
steps:
- uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- uses: gradle/actions/setup-gradle@v6
- name: Build XCFramework
run: ./gradlew --no-daemon :core:zipXCFramework
- name: Compute checksum
id: checksum
run: |
CHECKSUM=$(swift package compute-checksum core/build/xcframeworks/FeaturedCore.xcframework.zip)
echo "CHECKSUM=${CHECKSUM}" | tee -a "$GITHUB_OUTPUT"
- name: Create or update GitHub Release and upload XCFramework
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Create the release if it doesn't already exist (idempotent)
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes \
2>/dev/null || true
gh release upload "${{ github.ref_name }}" \
core/build/xcframeworks/FeaturedCore.xcframework.zip \
--clobber
- name: Update Package.swift checksum and URL
env:
TAG: ${{ github.ref_name }}
CHECKSUM: ${{ steps.checksum.outputs.CHECKSUM }}
run: |
ASSET_URL="https://github.com/AndroidBroadcast/Featured/releases/download/${TAG}/FeaturedCore.xcframework.zip"
sed -i '' \
-e "s|url: \".*FeaturedCore.xcframework.zip\"|url: \"${ASSET_URL}\"|" \
-e "s|checksum: \"[0-9a-f]*\"|checksum: \"${CHECKSUM}\"|" \
Package.swift
- name: Commit updated Package.swift
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Package.swift
git diff --cached --quiet && echo "No changes to commit" && exit 0
git commit -m "chore: update Package.swift checksum for ${{ github.ref_name }}"
# Fetch latest main first to reduce push conflicts
git fetch origin main
git push origin HEAD:main