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
35 changes: 35 additions & 0 deletions .github/workflows/publish-android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,41 @@ jobs:

- uses: android-actions/setup-android@40fd30fb8d7440372e1316f5d1809ec01dcd3699 # v4.0.1

- name: Verify Maven Central credentials
if: github.event_name == 'release' || inputs.publish
env:
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
run: |
set -euo pipefail

if [ -z "$MAVEN_CENTRAL_USERNAME" ] || [ -z "$MAVEN_CENTRAL_PASSWORD" ]; then
echo "MAVEN_CENTRAL_USERNAME and MAVEN_CENTRAL_PASSWORD secrets must be set."
exit 1
fi

TOKEN="$(printf '%s:%s' "$MAVEN_CENTRAL_USERNAME" "$MAVEN_CENTRAL_PASSWORD" | base64 | tr -d '\n')"
CODE="$(curl -sS -o /dev/null -w '%{http_code}' \
-H "Authorization: Bearer $TOKEN" \
"https://central.sonatype.com/api/v1/publisher/published?namespace=com.contentful.java&name=optimization-android&version=0.0.0-probe" || printf '000')"

case "$CODE" in
2*|404)
;;
401|403)
echo "Central Portal rejected the Maven Central token for namespace com.contentful.java (HTTP $CODE)."
echo "Regenerate a Central Portal user token from an account with publisher access to com.contentful.java and update the GitHub Actions secrets."
exit 1
;;
000)
echo "Could not reach the Central Portal API."
exit 1
;;
*)
echo "Central Portal credential preflight returned HTTP $CODE; continuing because the token was not explicitly rejected."
;;
esac

- name: Verify Maven publishing assembles
if: github.event_name == 'workflow_dispatch' && !inputs.publish
working-directory: packages/android/ContentfulOptimization
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/publish-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ jobs:

- name: Bump package.json versions
run: |
pnpm -r --filter "@contentful/optimization-*" exec \
pnpm -r --filter "@contentful/optimization-*" \
--filter "!@contentful/optimization-js-bridge" exec \
npm --no-git-tag-version --force version "$RELEASE_VERSION"
env:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}
Expand All @@ -71,12 +72,16 @@ jobs:
RELEASE_VERSION: ${{ env.RELEASE_VERSION }}

- name: Prepare package READMEs for publish
run: pnpm -r --filter "@contentful/optimization-*" exec build-tools rewrite-readme prepare
run: |
pnpm -r --filter "@contentful/optimization-*" \
--filter "!@contentful/optimization-js-bridge" exec build-tools rewrite-readme prepare
env:
RELEASE_TAG: ${{ env.RELEASE_TAG }}

- name: Create packages for troubleshooting
run: pnpm pack --filter "@contentful/optimization-*" --pack-destination pkgs
run: |
pnpm pack --filter "@contentful/optimization-*" \
--filter "!@contentful/optimization-js-bridge" --pack-destination pkgs

- name: Upload packages for troubleshooting
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
Expand All @@ -96,10 +101,14 @@ jobs:

- name: Publish
if: github.event_name == 'release' || inputs.publish
run: pnpm -r --filter "@contentful/optimization-*" publish --access public --no-git-checks
run: |
pnpm -r --filter "@contentful/optimization-*" \
--filter "!@contentful/optimization-js-bridge" publish --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ steps.vault.outputs.GITHUB_PACKAGES_WRITE_TOKEN }}

- name: Restore package READMEs after publish
if: always()
run: pnpm -r --filter "@contentful/optimization-*" exec build-tools rewrite-readme restore
run: |
pnpm -r --filter "@contentful/optimization-*" \
--filter "!@contentful/optimization-js-bridge" exec build-tools rewrite-readme restore
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"lint": "eslint lib packages",
"lint:fix": "eslint lib packages --fix",
"notices:generate": "pnpm --filter \"@contentful/*\" licenses list --prod --json | pnpm dlx @quantco/pnpm-licenses generate-disclaimer --json-input --output-file THIRD_PARTY_NOTICES.txt",
"pack:pkgs": "pnpm pack --filter @contentful/* --pack-destination pkgs",
"pack:pkgs": "pnpm pack --filter @contentful/* --filter '!@contentful/optimization-js-bridge' --pack-destination pkgs",
"playwright:install": "pnpm run implementation:run -- --all -- implementation:playwright:install",
"playwright:install-deps": "pnpm run implementation:run -- --all -- implementation:playwright:install-deps",
"pm2:delete:all": "pm2 delete all",
Expand Down
5 changes: 2 additions & 3 deletions packages/android/ContentfulOptimization/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.SonatypeHost

plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.compose")
// Version inline so the module builds when included as a subproject (parent builds don't pin it).
id("com.vanniktech.maven.publish") version "0.30.0"
id("com.vanniktech.maven.publish") version "0.34.0"
}

// Published coordinate: com.contentful.java:optimization-android. We reuse Contentful's existing,
Expand Down Expand Up @@ -97,7 +96,7 @@ mavenPublishing {
)
)

publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
publishToMavenCentral(automaticRelease = true)

// Sign with the in-memory GPG key supplied by CI (ORG_GRADLE_PROJECT_signingInMemoryKey*).
// Skipped automatically when no key is configured (e.g. local publishToMavenLocal smoke tests),
Expand Down
6 changes: 6 additions & 0 deletions packages/universal/optimization-js-bridge/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"private": true,
"name": "@contentful/optimization-js-bridge",
"version": "0.0.0",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/contentful/optimization.git",
"directory": "packages/universal/optimization-js-bridge"
},
"type": "module",
"main": "./dist/optimization-ios-bridge.umd.js",
"files": [
Expand Down
Loading