Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.12.2 #201

Merged
merged 3 commits into from
Nov 5, 2024
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
22 changes: 15 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Producer SDK Java CI with Maven

on:
push:
branches:
branches:
- develop
- master
pull_request:
Expand All @@ -12,31 +12,39 @@ on:

jobs:
build:
strategy:
# Unit and integration tests are not thread safe as they all use the same stream names.
max-parallel: 1
matrix:
os: [ macos-14, ubuntu-22.04, windows-2022 ]
java: [ 8, 11, 17, 21 ]

runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
strategy:
matrix:
os: [ macos-10.15, ubuntu-18.04, windows-2019]
java: [ 8, 11, 16 ]

steps:
- name: Checkout the repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
cache: maven

- name: Build with Maven
run: mvn clean compile assembly:single

- name: Run tests
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
Expand Down
13 changes: 11 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<groupId>com.amazonaws</groupId>
<artifactId>amazon-kinesis-video-streams-producer-sdk-java</artifactId>
<name>Amazon Kinesis Video Streams Producer SDK Java</name>
<version>1.12.1</version>
<version>1.12.2</version>
<description>The Amazon Kinesis Video Streams Producer SDK for Java enables Java developers to ingest data into
Amazon Kinesis Video.
</description>
Expand Down Expand Up @@ -133,7 +133,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
<version>2.14.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpasyncclient -->
<dependency>
Expand Down Expand Up @@ -220,6 +220,15 @@
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/pom.properties</include>
</includes>
</resource>
</resources>
</build>
</project>

16 changes: 15 additions & 1 deletion src/main/java/com/amazonaws/kinesisvideo/util/VersionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,24 @@
import com.amazonaws.kinesisvideo.common.preconditions.Preconditions;

import javax.annotation.Nonnull;
import java.io.IOException;
import java.util.Properties;

public final class VersionUtil {

public static final String AWS_SDK_KVS_PRODUCER_VERSION_STRING = "1.9.5";
private static final String POM_PROPERTIES_FILE = "pom.properties";
private static final String POM_PROPERTIES_VERSION_KEY = "version";
public static final String AWS_SDK_KVS_PRODUCER_VERSION_STRING;

static {
try {
final Properties properties = new Properties();
properties.load(VersionUtil.class.getClassLoader().getResourceAsStream(POM_PROPERTIES_FILE));
AWS_SDK_KVS_PRODUCER_VERSION_STRING = properties.getProperty(POM_PROPERTIES_VERSION_KEY);
} catch (IOException e) {
throw new ExceptionInInitializerError("Unable to get project version from pom.xml: " + e);
}
}

private static final String DEFAULT_USER_AGENT_NAME = "AWS-SDK-KVS";

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=${project.version}
60 changes: 60 additions & 0 deletions src/test/java/com/amazonaws/kinesisvideo/util/VersionUtilTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.amazonaws.kinesisvideo.util;

import org.junit.Test;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import static com.amazonaws.kinesisvideo.util.VersionUtil.AWS_SDK_KVS_PRODUCER_VERSION_STRING;
import static com.amazonaws.kinesisvideo.util.VersionUtil.getUserAgent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class VersionUtilTest {

private static final String POM_XML_LOCATION = "pom.xml";

@Test
public void test_versionString_isNotNullOrEmpty() {
final String producerVersionString = AWS_SDK_KVS_PRODUCER_VERSION_STRING;
assertNotNull(producerVersionString);
assertNotEquals("", producerVersionString);
}

@Test
public void test_versionString_isEqualToDeclaredInPomXML() throws IOException {
final String producerVersionString = extractVersionFromPomXML();

assertNotNull("project.version was not found in pom.xml!", producerVersionString);
assertNotEquals("", producerVersionString);
assertEquals(producerVersionString, AWS_SDK_KVS_PRODUCER_VERSION_STRING);
}

@Test
public void test_userAgent_containsProjectVersion() throws IOException {
final String userAgent = getUserAgent();
final String pomDefinedProjectVersion = extractVersionFromPomXML();

assertNotNull(userAgent);
assertNotEquals("", userAgent);

assertNotNull(pomDefinedProjectVersion);
assertNotEquals("", pomDefinedProjectVersion);

assertTrue(userAgent.contains(pomDefinedProjectVersion));
}

private String extractVersionFromPomXML() throws IOException {
try (final BufferedReader reader = new BufferedReader(new FileReader(POM_XML_LOCATION))) {
return reader.lines()
.filter(line -> line.contains("<version>"))
.map(line -> line.replace("<version>", "")
.replace("</version>", "").trim())
.findFirst()
.orElseThrow(() -> new IllegalStateException("'<version>projectVersion</version>' is not found in " + POM_XML_LOCATION));
}
}
}
Loading