diff --git a/.github/workflows/publish-to-code-artifact.yml b/.github/workflows/publish-to-code-artifact.yml new file mode 100644 index 0000000..3560a3d --- /dev/null +++ b/.github/workflows/publish-to-code-artifact.yml @@ -0,0 +1,43 @@ +name: Publish to CodeArtifact + +on: + release: + types: [published] + +env: + AWS_REGION: us-east-1 + +jobs: + publish: + runs-on: + group: Infrastructure + labels: [self-hosted, linux, arm64] + + steps: + - name: Checkout code + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 + + - name: Set up JDK + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0 + with: + java-version: '17' + distribution: 'corretto' + + - name: Login to CodeArtifact + run: | + export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token \ + --domain ${{ vars.CODEARTIFACT_DOMAIN }} \ + --domain-owner ${{ vars.CODEARTIFACT_DOMAIN_OWNER }} \ + --region ${{ env.AWS_REGION }} \ + --query authorizationToken \ + --output text) + echo "CODEARTIFACT_AUTH_TOKEN=$CODEARTIFACT_AUTH_TOKEN" >> $GITHUB_ENV + + - name: Build with Gradle + run: ./gradlew build + + - name: Run tests + run: ./gradlew test + + - name: Publish to CodeArtifact + run: ./gradlew publish diff --git a/README.md b/README.md index 9567fbd..5eb5590 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,32 @@ Beanie is a simple library to sanity-check your bean ser-deser. Beanie catches a ## Installation -Unfortunately, Beanie is not available in any public Maven repositories except the GitHub Package Registry. For more information on how to install packages -from the GitHub Package -Registry, [https://docs.github.com/en/packages/guides/configuring-gradle-for-use-with-github-packages#installing-a-package][see the GitHub docs] +Beanie artifacts are published to AWS CodeArtifact. Before building, fetch a temporary token and expose it to Gradle (tokens expire after 12 hours): + +``` +export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token \ + --domain \ + --domain-owner \ + --region us-east-1 \ + --query authorizationToken \ + --output text) +``` + +Then add the CodeArtifact repository to your `repositories` block: + +``` +repositories { + maven { + url = uri("https://nosto-673366506863.d.codeartifact.us-east-1.amazonaws.com/maven/java/") + credentials { + username = "aws" + password = System.getenv("CODEARTIFACT_AUTH_TOKEN") + } + } +} +``` + +After the repository is configured, declare the Beanie modules you need in `dependencies` as usual. ## Usage diff --git a/build.gradle b/build.gradle index b9bc8a3..bce63c6 100644 --- a/build.gradle +++ b/build.gradle @@ -165,9 +165,12 @@ allprojects { project -> publishing { repositories { maven { - name = "github" - url = uri("https://maven.pkg.github.com/nosto/beanie") - credentials(PasswordCredentials) + name = "codeartifact" + url = uri("https://nosto-673366506863.d.codeartifact.us-east-1.amazonaws.com/maven/java/") + credentials { + username = "aws" + password = System.getenv("CODEARTIFACT_AUTH_TOKEN") + } } } publications {