Skip to content

Commit dd75c43

Browse files
authored
Publish -SNAPSHOT artifacts to a codeartifact account (#1)
added deployment workflow for RIC
1 parent 34ff1a9 commit dd75c43

File tree

7 files changed

+97
-23
lines changed

7 files changed

+97
-23
lines changed

.github/workflows/aws-lambda-java-runtime-interface-client.yml

+32
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,35 @@ jobs:
6262
name: the-jar
6363
path: ./aws-lambda-java-runtime-interface-client/target/aws-lambda-java-runtime-interface-client-*.jar
6464

65+
publish:
66+
needs: build
67+
if: github.ref == 'refs/heads/main'
68+
69+
permissions:
70+
id-token: write
71+
contents: read
72+
73+
steps:
74+
- name: Issue AWS credentials
75+
uses: aws-actions/configure-aws-credentials@v1
76+
with:
77+
aws-region: ${{ secrets.AWS_REGION }}
78+
role-to-assume: ${{ secrets.AWS_ROLE }}
79+
role-session-name: GitHubActionsPublishPackage
80+
role-duration-seconds: 900
81+
82+
- name: Prepare codeartifact properties
83+
working-directory: ./aws-lambda-java-runtime-interface-client/ric-dev-environment
84+
run: |
85+
cat <<EOF > codeartifact-properties.mk
86+
CODE_ARTIFACT_REPO_ACCOUNT=${{ secrets.AWS_ACCOUNT }}
87+
CODE_ARTIFACT_REPO_REGION=${{ env.AWS_REGION }}
88+
CODE_ARTIFACT_REPO_NAME=${{ secrets.CODE_ARTIFACT_REPO_NAME }}
89+
CODE_ARTIFACT_DOMAIN=${{ secrets.AWS_CODEARTIFACT_DOMAIN }}
90+
EOF
91+
92+
- name: Publish
93+
working-directory: ./aws-lambda-java-runtime-interface-client
94+
env:
95+
ENABLE_SNAPSHOT: ${{ secrets.ENABLE_SNAPSHOT }}
96+
run: make publish
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
compile-flags.txt
2-
ric-dev-environment/dev-maven-repo.mk
2+
ric-dev-environment/codeartifact-properties.mk

aws-lambda-java-runtime-interface-client/Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ARCHITECTURE_ALIAS := $($(shell echo "$(ARCHITECTURE)_ALIAS"))
55
ARCHITECTURE_ALIAS := $(or $(ARCHITECTURE_ALIAS),amd64) # on any other archs defaulting to amd64
66

77
# This optional module exports MAVEN_REPO_URL, MAVEN_REPO_USERNAME and MAVEN_REPO_PASSWORD environment variables
8-
# making it possible to publish resulting artifacts to a development maven repository
9-
-include ric-dev-environment/dev-maven-repo.mk
8+
# making it possible to publish resulting artifacts to a codeartifact maven repository
9+
-include ric-dev-environment/codeartifact-repo.mk
1010

1111
.PHONY: target
1212
target:
@@ -48,7 +48,7 @@ build:
4848

4949
.PHONY: publish
5050
publish:
51-
mvn deploy --settings ric-dev-environment/settings.xml
51+
./ric-dev-environment/publish_snapshot.sh
5252

5353
define HELP_MESSAGE
5454

aws-lambda-java-runtime-interface-client/pom.xml

+9-11
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,6 @@
184184
<profiles>
185185
<profile>
186186
<id>dev</id>
187-
<activation>
188-
<file>
189-
<exists>ric-dev-environment/dev-maven-repo.mk</exists>
190-
</file>
191-
</activation>
192-
<distributionManagement>
193-
<snapshotRepository>
194-
<id>dev-snapshot-repo</id>
195-
<url>${env.MAVEN_REPO_URL}</url>
196-
</snapshotRepository>
197-
</distributionManagement>
198187
<build>
199188
<plugins>
200189
<plugin>
@@ -277,5 +266,14 @@
277266
</plugins>
278267
</build>
279268
</profile>
269+
<profile>
270+
<id>ci-repo</id>
271+
<distributionManagement>
272+
<repository>
273+
<id>ci-repo</id>
274+
<url>${env.MAVEN_REPO_URL}</url>
275+
</repository>
276+
</distributionManagement>
277+
</profile>
280278
</profiles>
281279
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
ifneq ("$(wildcard ric-dev-environment/codeartifact-properties.mk)","")
3+
4+
include ric-dev-environment/codeartifact-properties.mk
5+
$(info Found codeartifact-properties.mk module)
6+
7+
export MAVEN_REPO_URL:=$(shell aws codeartifact get-repository-endpoint \
8+
--domain ${CODE_ARTIFACT_DOMAIN} \
9+
--repository ${CODE_ARTIFACT_REPO_NAME} \
10+
--format maven \
11+
--output text \
12+
--region ${CODE_ARTIFACT_REPO_REGION})
13+
14+
export MAVEN_REPO_PASSWORD:=$(shell aws codeartifact get-authorization-token \
15+
--domain ${CODE_ARTIFACT_DOMAIN} \
16+
--domain-owner ${CODE_ARTIFACT_REPO_ACCOUNT} \
17+
--query authorizationToken \
18+
--output text \
19+
--region ${CODE_ARTIFACT_REPO_REGION})
20+
21+
export MAVEN_REPO_USERNAME:=aws
22+
23+
$(info MAVEN_REPO_URL: $(MAVEN_REPO_URL))
24+
# $(info MAVEN_REPO_PASSWORD: $(MAVEN_REPO_PASSWORD))
25+
$(info MAVEN_REPO_USERNAME: $(MAVEN_REPO_USERNAME))
26+
$(info CODE_ARTIFACT_REPO_NAME: $(CODE_ARTIFACT_REPO_NAME))
27+
endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
projectVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
6+
if [[ -z ${ENABLE_SNAPSHOT} ]]; then
7+
echo "Skipping SNAPSHOT deployment, as ENABLE_SNAPSHOT environment variable is not defined"
8+
exit
9+
fi
10+
11+
echo "Deploying SNAPSHOT artifact"
12+
if [[ ${projectVersion} != *"SNAPSHOT"* ]]; then
13+
snapshotProjectVersion="${projectVersion}-SNAPSHOT"
14+
echo "projectVersion: ${projectVersion}"
15+
echo "snapshotProjectVersion: ${snapshotProjectVersion}"
16+
mvn versions:set "-DnewVersion=${snapshotProjectVersion}"
17+
else
18+
echo "Already -SNAPSHOT version"
19+
fi
20+
21+
mvn -P ci-repo deploy --settings ric-dev-environment/settings.xml
22+
mv pom.xml.versionsBackup pom.xml

aws-lambda-java-runtime-interface-client/ric-dev-environment/settings.xml

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
<settings>
22
<profiles>
33
<profile>
4-
<id>dev</id>
5-
<activation>
6-
<file>
7-
<exists>dev-maven-repo.mk</exists>
8-
</file>
9-
</activation>
4+
<id>dev-ci</id>
105
<repositories>
116
<repository>
12-
<id>dev-snapshot-repo</id>
7+
<id>ci-repo</id>
138
<url>${env.MAVEN_REPO_URL}</url>
149
</repository>
1510
</repositories>
1611
</profile>
1712
</profiles>
1813
<servers>
1914
<server>
20-
<id>dev-snapshot-repo</id>
15+
<id>ci-repo</id>
2116
<username>${env.MAVEN_REPO_USERNAME}</username>
2217
<password>${env.MAVEN_REPO_PASSWORD}</password>
2318
</server>

0 commit comments

Comments
 (0)