diff --git a/.bump_version.toml b/.bump_version.toml new file mode 100644 index 0000000..71b15bb --- /dev/null +++ b/.bump_version.toml @@ -0,0 +1,21 @@ +[tool.bumpversion] +commit = false +tag = false +current_version = "placeholder_version" +parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)(\\-(?P[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" + diff --git a/.github/workflows/create-pr.yml b/.github/workflows/create-pr.yml new file mode 100644 index 0000000..f92a653 --- /dev/null +++ b/.github/workflows/create-pr.yml @@ -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 }} diff --git a/.github/workflows/publish-maven.yml b/.github/workflows/publish-maven.yml index 64ffefc..065db40 100644 --- a/.github/workflows/publish-maven.yml +++ b/.github/workflows/publish-maven.yml @@ -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 "github-actions@github.com" + 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' diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index ee3e115..62d9643 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,3 +1,4 @@ +.bump_version.toml .github/workflows/build-maven.yml .gitignore .openapi-generator-ignore diff --git a/README.md b/README.md index 6b05248..b5530f5 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Add this dependency to your project's POM: com.fireblocks.sdk fireblocks-sdk - 2.1.0 + 0.0.0 compile ``` @@ -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 @@ -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` diff --git a/build.gradle b/build.gradle index eef7ac4..358eefb 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/pom.xml b/pom.xml index f9ad2d8..94938f5 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ fireblocks-sdk jar fireblocks-sdk - 2.1.0 + 0.0.0 https://github.com/fireblocks/java-sdk 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'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's capabilities while adhering to best practices in security and efficiency. diff --git a/src/main/java/com/fireblocks/sdk/Configuration.java b/src/main/java/com/fireblocks/sdk/Configuration.java index f1c19d3..9ec56d0 100644 --- a/src/main/java/com/fireblocks/sdk/Configuration.java +++ b/src/main/java/com/fireblocks/sdk/Configuration.java @@ -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(); diff --git a/src/main/java/com/fireblocks/sdk/UserAgentUtil.java b/src/main/java/com/fireblocks/sdk/UserAgentUtil.java index 882448c..50c2f02 100644 --- a/src/main/java/com/fireblocks/sdk/UserAgentUtil.java +++ b/src/main/java/com/fireblocks/sdk/UserAgentUtil.java @@ -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)) { diff --git a/src/test/java/com/fireblocks/sdk/FireblocksTest.java b/src/test/java/com/fireblocks/sdk/FireblocksTest.java index 861a636..d20cfb1 100644 --- a/src/test/java/com/fireblocks/sdk/FireblocksTest.java +++ b/src/test/java/com/fireblocks/sdk/FireblocksTest.java @@ -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; @@ -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)); } } @@ -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)); } } diff --git a/src/test/java/com/fireblocks/sdk/UserAgentUtilTest.java b/src/test/java/com/fireblocks/sdk/UserAgentUtilTest.java index 64f9452..c46264b 100644 --- a/src/test/java/com/fireblocks/sdk/UserAgentUtilTest.java +++ b/src/test/java/com/fireblocks/sdk/UserAgentUtilTest.java @@ -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; @@ -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 @@ -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); } } @@ -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); } } }