Update deploy.yml #37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Maven Central | |
on: | |
push: | |
branches: | |
- main # Trigger deployment only on the main branch | |
permissions: | |
contents: read | |
id-token: write | |
jobs: | |
deploy: | |
runs-on: macos-latest # Use macOS for iOS builds | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up JDK | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Install Xcode Command Line Tools | |
run: | | |
xcode-select --install || echo "Xcode Command Line Tools already installed" | |
# Step 3: Import GPG key (securely) | |
- name: Import GPG key | |
run: | | |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import | |
echo "use-agent" >> ~/.gnupg/gpg.conf | |
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf | |
gpg --list-secret-keys --keyid-format LONG > /dev/null | |
env: | |
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
# Step 4: Configure Maven settings (securely) | |
- name: Configure Maven settings | |
run: | | |
mkdir -p ~/.m2 | |
cat <<EOF > ~/.m2/settings.xml | |
<settings> | |
<servers> | |
<server> | |
<id>ossrh</id> | |
<username>${{ secrets.OSSRH_USERNAME }}</username> | |
<password>${{ secrets.OSSRH_PASSWORD }}</password> | |
</server> | |
</servers> | |
</settings> | |
EOF | |
- name: Verify Maven settings | |
run: ls -la ~/.m2 | |
- name: Verify gradle tasks Available | |
uses: ./gradlew tasks | |
- name: Build Android and Common Artifacts | |
run: ./gradlew clean assemble --no-configuration-cache | |
- name: Build iOS Artifacts | |
run: | | |
./gradlew :shared:linkReleaseFrameworkIosArm64 | |
./gradlew :shared:linkReleaseFrameworkIosSimulatorArm64 | |
# Step 5: Verify Generated Artifacts for Kotlin Multiplatform | |
- name: Verify Generated Artifacts | |
run: | | |
if [ ! -d "./shared/build/libs" ]; then | |
echo "No artifacts found for Android! Ensure the Android artifacts are generated in './shared/build/libs'." | |
exit 1 | |
fi | |
if [ ! -d "./shared/build/bin/iosArm64" ]; then | |
echo "No artifacts found for iOS Arm64! Ensure the iOS artifacts are generated in './shared/build/bin/iosArm64'." | |
exit 1 | |
fi | |
if [ ! -d "./shared/build/bin/iosSimulatorArm64" ]; then | |
echo "No artifacts found for iOS Simulator Arm64! Ensure the iOS artifacts are generated in './shared/build/bin/iosSimulatorArm64'." | |
exit 1 | |
fi | |
echo "Artifacts verified successfully!" | |
# Step 6: Build and Publish to Maven Central | |
- name: Build and publish | |
run: ./gradlew clean publishAllPublicationsToMavenCentralRepository --no-configuration-cache --info --stacktrace | |
env: | |
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} |