Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ on:

jobs:
publish-github:
# The canonical repository publishes when its release PR is merged. A synchronized copy does
# not number releases (see version.yaml): it tags and publishes the version that a merged
# synchronization PR brings in.
if: |
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
(
startsWith(github.event.pull_request.head.ref, 'release/') ||
(
github.repository_owner_id != '6458050' &&
startsWith(github.event.pull_request.head.ref, 'sync/')
)
)
)
runs-on: ubuntu-latest
permissions: write-all
Expand All @@ -33,25 +42,57 @@ jobs:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}

- name: Generate versioner token
if: github.repository_owner_id != '6458050'
id: versioner-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.VERSIONER_ID }}
private-key: ${{ secrets.VERSIONER_SECRET }}

# A copy has no semantic-release run to tag for it. The tag is what JitPack builds and what
# the GitHub release hangs on; an existing one means this version is already out, so the
# rest of the job is skipped instead of publishing it twice.
- name: Tag the synchronized version
if: github.repository_owner_id != '6458050'
id: tag
env:
GH_TOKEN: ${{ steps.versioner-token.outputs.token }}
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
run: |
version=$(grep -m1 VERSION_NAME version.properties | cut -d'=' -f2)
tag="v$version"
if gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$tag" >/dev/null 2>&1; then
echo "$tag already exists, nothing to publish"
echo "publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi
gh api -X POST "repos/$GITHUB_REPOSITORY/git/refs" -f ref="refs/tags/$tag" -f sha="$MERGE_SHA"
gh release create "$tag" --title "$tag" --generate-notes

- name: Set up Java
if: steps.tag.outputs.publish != 'false'
uses: actions/setup-java@v4
with:
java-version: 22
distribution: 'zulu'

- name: Set up Gradle
if: steps.tag.outputs.publish != 'false'
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.8

- name: Decode signing key file
if: steps.tag.outputs.publish != 'false'
uses: timheuer/[email protected]
with:
fileName: com.rees46.key.gpg
fileDir: ./personalization-sdk
encodedString: ${{ secrets.SIGNING_KEY_FILE_AS_BASE64_STRING }}

- name: Configure gradle.properties for GitHub Packages
if: steps.tag.outputs.publish != 'false'
run: |
echo "github=true" >> gradle.properties
# Use the same OSSRH credentials that were used before (GitHub credentials)
Expand All @@ -70,9 +111,11 @@ jobs:
echo "Updated gradle.properties for GitHub Packages"

- name: Clean
if: steps.tag.outputs.publish != 'false'
run: ./gradlew clean

- name: Publish to GitHub Packages
if: steps.tag.outputs.publish != 'false'
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
run: ./gradlew publishToGitHubPackages
13 changes: 8 additions & 5 deletions .github/workflows/sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ on:

jobs:
prepare:
# Synchronization starts in the canonical repository only; a copy has nowhere to sync to.
if: |
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
github.repository_owner_id == '6458050' && (
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
)
)
runs-on: ubuntu-latest
outputs:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ jobs:

bump-version:
needs: find-release-commit
# Only the canonical repository (matched by owner id, which synchronization leaves as it is)
# numbers releases. A synchronized copy publishes the version synchronization brings it, so
# both carry the same number.
if: |
github.event_name == 'workflow_dispatch' || (
github.event_name == 'push' &&
needs.find-release-commit.outputs.hasCommit == 'false')
github.repository_owner_id == '6458050' && (
github.event_name == 'workflow_dispatch' || (
github.event_name == 'push' &&
needs.find-release-commit.outputs.hasCommit == 'false'))
uses: rees46/workflow/.github/workflows/reusable-multiplatform-version-bump.yaml@master
permissions: write-all
secrets:
Expand Down
Loading