Skip to content

Commit

Permalink
Generated SDK #2873 (#61)
Browse files Browse the repository at this point in the history
Co-authored-by: fireblocks_dx_team <[email protected]>
  • Loading branch information
github-actions[bot] and fireblocks_dx_team authored Jun 27, 2024
1 parent 3ba1cd0 commit 5ea3717
Show file tree
Hide file tree
Showing 11 changed files with 118 additions and 16 deletions.
21 changes: 21 additions & 0 deletions .bump_version.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.bumpversion]
commit = false
tag = false
current_version = "placeholder_version"
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(\\-(?P<release>[a-z]+))?"
serialize = [
"{major}.{minor}.{patch}-{release}",
"{major}.{minor}.{patch}"
]
[[tool.bumpversion.files]]
filename = "pom.xml"

[[tool.bumpversion.files]]
filename = "build.gradle"

[[tool.bumpversion.files]]
filename = "README.md"

[[tool.bumpversion.files]]
filename = "src/main/java/com/fireblocks/sdk/Configuration.java"

25 changes: 25 additions & 0 deletions .github/workflows/create-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Create Pull Request

on:
push:
branches:
- 'fireblocks-api-spec/generated/*'

jobs:
create-pull-request:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Create pull request
run: |
gh pr create \
--title "${{ github.event.commits[0].message }}" \
--body "This PR was automatically generated." \
--base master \
--head ${{ github.ref }} \
--reviewer asafs932,zoharsf,YoavBZ
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50 changes: 48 additions & 2 deletions .github/workflows/publish-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,60 @@ on:
types: [published]

jobs:
bump-version:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
token: ${{ secrets.RELEASE_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bump-my-version
- name: Bump version
run: |
initialTag=${{ github.event.release.tag_name }}
tag="${initialTag//[v]/}"
echo $tag
git remote update
git fetch
echo "finished fetching"
git checkout --track origin/master
echo "finished checkout"
git config --global user.email "[email protected]"
git config --global user.name "Github Actions"
echo "finished configuration"
bump-my-version bump --config-file .bump_version.toml --current-version 0.0.0 --new-version $tag
echo "bumpversion finished"
git add .
git commit -m "release $tag"
git push
- name: Move tag
run: |
TAG_NAME=${{ github.event.release.tag_name }}
echo $tag
git tag --force $TAG_NAME
git push --force origin $TAG_NAME
publish:
needs: bump-version
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
- name: Check out repository code
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
Expand Down
1 change: 1 addition & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.bump_version.toml
.github/workflows/build-maven.yml
.gitignore
.openapi-generator-ignore
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Add this dependency to your project's POM:
<dependency>
<groupId>com.fireblocks.sdk</groupId>
<artifactId>fireblocks-sdk</artifactId>
<version>2.1.0</version>
<version>0.0.0</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -42,7 +42,7 @@ Add this dependency to your project's POM:
Add this dependency to your project's build file:

```groovy
compile "com.fireblocks.sdk:fireblocks-sdk:2.1.0"
compile "com.fireblocks.sdk:fireblocks-sdk:0.0.0"
```

### Others
Expand All @@ -55,7 +55,7 @@ mvn clean package

Then manually install the following JARs:

- `target/fireblocks-sdk-2.1.0.jar`
- `target/fireblocks-sdk-0.0.0.jar`
- `target/lib/*.jar`


Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'eclipse'
apply plugin: 'com.diffplug.spotless'

group = 'com.fireblocks.sdk'
version = '2.1.0'
version = '0.0.0'

buildscript {
repositories {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<artifactId>fireblocks-sdk</artifactId>
<packaging>jar</packaging>
<name>fireblocks-sdk</name>
<version>2.1.0</version>
<version>0.0.0</version>
<url>https://github.com/fireblocks/java-sdk</url>
<description>The Fireblocks Official SDK is a comprehensive software development kit that enables seamless integration and interaction with the Fireblocks platform. Fireblocks is a cutting-edge blockchain infrastructure platform that provides secure and scalable solutions for managing digital assets and transactions.
This SDK empowers developers to build robust applications that can interact with the Fireblocks platform&#39;s features, including creating and managing vault accounts, initiating secure transactions, managing assets, and more. It abstracts complex interactions with the Fireblocks API, making it easier for developers to leverage the platform&#39;s capabilities while adhering to best practices in security and efficiency.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/fireblocks/sdk/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class Configuration {
public static final String VERSION = "2.1.0";
public static final String VERSION = "0.0.0";

private static ApiClient defaultApiClient = new ApiClient();

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/fireblocks/sdk/UserAgentUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
import java.util.Optional;

public class UserAgentUtil {

public static String getUserAgent(AdditionalOptions additionalOptions) {
String sdkVersion = "2.1.0";
String userAgent = "fireblocks/sdk/java/" + sdkVersion;
String userAgent = "fireblocks/sdk/java/" + Configuration.VERSION;
if (!Optional.ofNullable(additionalOptions)
.map(AdditionalOptions::isAnonymousPlatform)
.orElse(false)) {
Expand Down
7 changes: 5 additions & 2 deletions src/test/java/com/fireblocks/sdk/FireblocksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.auth0.jwt.algorithms.Algorithm;
import com.fireblocks.sdk.AdditionalOptions;
import com.fireblocks.sdk.ApiClient;
import com.fireblocks.sdk.Configuration;
import com.fireblocks.sdk.ConfigurationOptions;
import com.fireblocks.sdk.Fireblocks;
import com.fireblocks.sdk.InstanceTimeWrapper;
Expand Down Expand Up @@ -122,7 +123,8 @@ private void runAndVerifyAuthorizationValue(
Assert.assertEquals(expectedAuthorizationValue, headerMap.get("Authorization").get(0));
Assert.assertEquals("application/json", headerMap.get("Content-Type").get(0));
Assert.assertEquals(
"testUserAgent fireblocks/sdk/java/2.1.0", headerMap.get("User-Agent").get(0));
"testUserAgent fireblocks/sdk/java/" + Configuration.VERSION,
headerMap.get("User-Agent").get(0));
Assert.assertEquals("testApiKey", headerMap.get("X-API-Key").get(0));
}
}
Expand Down Expand Up @@ -255,7 +257,8 @@ public void testHeadersExistsInRequest() {
Assert.assertEquals("Bearer mockJwt", headerMap.get("Authorization").get(0));
Assert.assertEquals("application/json", headerMap.get("Content-Type").get(0));
Assert.assertEquals(
"testUserAgent fireblocks/sdk/java/2.1.0", headerMap.get("User-Agent").get(0));
"testUserAgent fireblocks/sdk/java/" + Configuration.VERSION,
headerMap.get("User-Agent").get(0));
Assert.assertEquals("testApiKey", headerMap.get("X-API-Key").get(0));
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/test/java/com/fireblocks/sdk/UserAgentUtilTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import static org.mockito.Mockito.*;

import com.fireblocks.sdk.AdditionalOptions;
import com.fireblocks.sdk.Configuration;
import com.fireblocks.sdk.SystemWrapper;
import com.fireblocks.sdk.UserAgentUtil;
import org.junit.Assert;
Expand All @@ -14,7 +15,7 @@ public class UserAgentUtilTest {
public void testGetUserAgentWithAnonymousPlatform() {
AdditionalOptions additionalOptions = new AdditionalOptions().isAnonymousPlatform(true);
String userAgent = UserAgentUtil.getUserAgent(additionalOptions);
Assert.assertEquals("fireblocks/sdk/java/2.1.0", userAgent);
Assert.assertEquals("fireblocks/sdk/java/" + Configuration.VERSION, userAgent);
}

@Test
Expand All @@ -26,7 +27,11 @@ public void testGetUserAgentWithoutAnonymousPlatform() {
mockedSystem.when(() -> SystemWrapper.getProperty("os.version")).thenReturn("10.15.7");
mockedSystem.when(() -> SystemWrapper.getProperty("os.arch")).thenReturn("x86_64");
String userAgent = UserAgentUtil.getUserAgent(additionalOptions);
Assert.assertEquals("fireblocks/sdk/java/2.1.0 (macOS 10.15.7; x86_64)", userAgent);
Assert.assertEquals(
String.format(
"fireblocks/sdk/java/%s (macOS 10.15.7; x86_64)",
Configuration.VERSION),
userAgent);
}
}

Expand All @@ -41,7 +46,10 @@ public void testGetUserAgentWithCustomUserAgent() {
mockedSystem.when(() -> SystemWrapper.getProperty("os.arch")).thenReturn("x86_64");
String userAgent = UserAgentUtil.getUserAgent(additionalOptions);
Assert.assertEquals(
"customUserAgent fireblocks/sdk/java/2.1.0 (macOS 10.15.7; x86_64)", userAgent);
String.format(
"customUserAgent fireblocks/sdk/java/%s (macOS 10.15.7; x86_64)",
Configuration.VERSION),
userAgent);
}
}
}

0 comments on commit 5ea3717

Please sign in to comment.