|
| 1 | +# Publishes the Pulse library modules to GitHub Packages whenever a version |
| 2 | +# tag (e.g. 0.3.5) is pushed. The pushed tag is the single source of truth for |
| 3 | +# the published version. |
| 4 | +name: Publish |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - '[0-9]+.[0-9]+.[0-9]+' # 0.3.5 |
| 10 | + - 'v[0-9]+.[0-9]+.[0-9]+' # v0.3.5 (optional 'v' prefix is stripped) |
| 11 | + # Allow a manual run from the Actions tab, supplying the version explicitly. |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + version: |
| 15 | + description: 'Version to publish (e.g. 0.3.5)' |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + |
| 19 | +# Never run two publishes for the same ref at once, and don't cancel a publish |
| 20 | +# that is already in flight. |
| 21 | +concurrency: |
| 22 | + group: publish-${{ github.ref }} |
| 23 | + cancel-in-progress: false |
| 24 | + |
| 25 | +jobs: |
| 26 | + publish: |
| 27 | + # Ubuntu cross-compiles every target from one job. A KMP *library* publishes |
| 28 | + # klibs, and Kotlin/Native compiles Apple-target klibs on any host (these |
| 29 | + # modules have no Apple-framework cinterop). Only linking final iOS |
| 30 | + # .framework binaries would require macOS — publishing klibs does not. |
| 31 | + runs-on: ubuntu-latest |
| 32 | + permissions: |
| 33 | + contents: read |
| 34 | + packages: write # lets the built-in GITHUB_TOKEN push packages |
| 35 | + |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + # JDK 21 / Temurin matches gradle/gradle-daemon-jvm.properties so Gradle |
| 41 | + # does not try to auto-provision a different daemon JVM. |
| 42 | + - name: Set up JDK 21 |
| 43 | + uses: actions/setup-java@v4 |
| 44 | + with: |
| 45 | + distribution: temurin |
| 46 | + java-version: '21' |
| 47 | + |
| 48 | + # The repo ships only gradle-wrapper.jar (no gradlew script), so provision |
| 49 | + # the matching Gradle version directly instead of calling ./gradlew. |
| 50 | + - name: Set up Gradle |
| 51 | + uses: gradle/actions/setup-gradle@v4 |
| 52 | + with: |
| 53 | + gradle-version: '9.4.1' |
| 54 | + |
| 55 | + # Resolve the version from the tag (push) or the manual input (dispatch). |
| 56 | + - name: Resolve version |
| 57 | + id: version |
| 58 | + run: | |
| 59 | + if [ "${{ github.ref_type }}" = "tag" ]; then |
| 60 | + VERSION="${GITHUB_REF_NAME#v}" # strip an optional leading 'v' |
| 61 | + else |
| 62 | + VERSION="${{ inputs.version }}" |
| 63 | + fi |
| 64 | + if [ -z "$VERSION" ]; then |
| 65 | + echo "::error::No version could be resolved." && exit 1 |
| 66 | + fi |
| 67 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 68 | + echo "Publishing version: $VERSION" |
| 69 | +
|
| 70 | + # Publish only to the remote GitHub Packages repository (not mavenLocal). |
| 71 | + # The URL is pinned to the canonical repo name so the GITHUB_TOKEN scope |
| 72 | + # always matches the publish target. |
| 73 | + - name: Publish to GitHub Packages |
| 74 | + env: |
| 75 | + PULSE_MAVEN_USERNAME: ${{ github.actor }} |
| 76 | + PULSE_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + run: > |
| 78 | + gradle publishAllPublicationsToRemoteRepository |
| 79 | + -Ppulse.version=${{ steps.version.outputs.version }} |
| 80 | + -Ppulse.snapshot=false |
| 81 | + -Ppulse.maven.url=https://maven.pkg.github.com/${{ github.repository }} |
| 82 | + --no-configuration-cache |
| 83 | + --stacktrace |
0 commit comments