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
48 changes: 48 additions & 0 deletions .github/workflows/publish-to-codeartifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: '21'
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)
cat <<EOS > gradle.properties
mavenUrl=${{ vars.CODEARTIFACT_DOMAIN }}-${{ vars.CODEARTIFACT_DOMAIN_OWNER }}.d.codeartifact.${{ env.AWS_REGION }}.amazonaws.com/maven/java
mavenUser=aws
mavenPassword=$CODEARTIFACT_AUTH_TOKEN
EOS

- name: Build with Gradle
run: ./gradlew build

- name: Run tests
run: ./gradlew test

- name: Publish to CodeArtifact
run: ./gradlew publish

23 changes: 8 additions & 15 deletions framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import org.yaml.snakeyaml.Yaml
buildscript {
repositories {
maven {
url "https://repo.nos.to/content/repositories/central/"
name = "codeartifact"
url = "$mavenUrl"
credentials {
username = "$mavenUser"
password = "$mavenPassword"
Expand Down Expand Up @@ -54,21 +55,13 @@ def deps = new Yaml().load(file("dependencies.yml").text)
repositories {
mavenLocal()
maven {
name "NostoCentral"
url "https://repo.nos.to/content/repositories/central/"
name = "codeartifact"
url = "$mavenUrl"
credentials {
username = "$mavenUser"
password = "$mavenPassword"
}
}
maven {
name "NostoDependencies"
url 'https://repo.nos.to/content/repositories/NostoDependencies/'
credentials {
username "$mavenUser"
password "$mavenPassword"
}
}
}

dependencies {
Expand Down Expand Up @@ -217,11 +210,11 @@ publishing {
}
repositories {
maven {
name "NostoDependencies"
url 'https://repo.nos.to/content/repositories/NostoDependencies/'
name = "codeartifact"
url = "$mavenUrl"
credentials {
username "$mavenUser"
password "$mavenPassword"
username = "$mavenUser"
password = "$mavenPassword"
Comment on lines +214 to +217
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume these 3 come from Gradle itself?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so. I assume there's no difference whether there is the equals sign or if it's omitted.

}
}
}
Expand Down