diff --git a/.github/workflows/bump-sdk.yml b/.github/workflows/bump-sdk.yml new file mode 100644 index 0000000000..0d3f3270e2 --- /dev/null +++ b/.github/workflows/bump-sdk.yml @@ -0,0 +1,86 @@ +name: Bump SDK Version + +permissions: + contents: write + +on: + workflow_dispatch: + inputs: + version_type: + description: "Version increment type" + required: false + default: "patch" + type: choice + options: + - patch + - minor + - major + - custom + custom_version: + description: "Custom version (if version_type is custom)" + required: false + default: "" + type: string + +jobs: + bump-sdk: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: "20" + + - name: Import GPG Key + run: | + echo "${{ secrets.GPG_KEY }}" | gpg --batch --import + git config --global user.email "dev-bot@gmx.io" + git config --global user.name "GMX Release Bot" + GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format=long | grep '^sec' | tail -1 | awk '{print $2}' | cut -d'/' -f2) + git config --global user.signingkey $GPG_KEY_ID + git config --global gpg.program gpg + git config --global commit.gpgsign true + env: + GPG_KEY: ${{ secrets.GPG_KEY }} + + - name: Install dependencies + working-directory: ./sdk + run: yarn install --immutable + + - name: Build package + working-directory: ./sdk + run: | + yarn prepare + yarn prebuild + yarn build + + - name: Bump version + working-directory: ./sdk + run: | + if [ "${{ github.event.inputs.version_type }}" == "custom" ]; then + if [ -z "${{ github.event.inputs.custom_version }}" ]; then + echo "Custom version not specified" + exit 1 + fi + yarn version "${{ github.event.inputs.custom_version }}" + else + yarn version ${{ github.event.inputs.version_type }} + fi + + - name: Commit version bump + working-directory: ./sdk + run: | + git add package.json + git commit -S -m "Bump SDK version to $(jq -r .version package.json)" + + - name: Push changes + run: | + if [ "${{ github.event.inputs.version_type }}" == "custom" ]; then + exit 0 + fi + git push origin HEAD:${{ github.ref_name }} diff --git a/.github/workflows/publish-sdk.yml b/.github/workflows/publish-sdk.yml index 2bf4520508..9904da9f47 100644 --- a/.github/workflows/publish-sdk.yml +++ b/.github/workflows/publish-sdk.yml @@ -5,26 +5,11 @@ permissions: on: workflow_dispatch: - inputs: - version_type: - description: "Version increment type" - required: false - default: "patch" - type: choice - options: - - patch - - minor - - major - - custom - custom_version: - description: "Custom version (if version_type is custom)" - required: false - default: "" - type: string jobs: - publish: + publish-sdk: runs-on: ubuntu-latest + environment: sdk_deploy steps: - name: Checkout code uses: actions/checkout@v4 @@ -40,18 +25,6 @@ jobs: scope: "@gmx-io" auth-token: ${{ secrets.NPM_TOKEN }} - - name: Import GPG Key - run: | - echo "${{ secrets.GPG_KEY }}" | gpg --batch --import - git config --global user.email "dev-bot@gmx.io" - git config --global user.name "GMX Release Bot" - GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format=long | grep '^sec' | tail -1 | awk '{print $2}' | cut -d'/' -f2) - git config --global user.signingkey $GPG_KEY_ID - git config --global gpg.program gpg - git config --global commit.gpgsign true - env: - GPG_KEY: ${{ secrets.GPG_KEY }} - - name: Install dependencies working-directory: ./sdk run: yarn install --immutable @@ -63,33 +36,7 @@ jobs: yarn prebuild yarn build - - name: Bump version - working-directory: ./sdk - run: | - if [ "${{ github.event.inputs.version_type }}" == "custom" ]; then - if [ -z "${{ github.event.inputs.custom_version }}" ]; then - echo "Custom version not specified" - exit 1 - fi - yarn version "${{ github.event.inputs.custom_version }}" - else - yarn version ${{ github.event.inputs.version_type }} - fi - - - name: Commit version bump - working-directory: ./sdk - run: | - git add package.json - git commit -S -m "Bump SDK version to $(jq -r .version package.json)" - - run: npm publish --access public working-directory: ./sdk env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: Push changes - run: | - if [ "${{ github.event.inputs.version_type }}" == "custom" ]; then - exit 0 - fi - git push origin HEAD:${{ github.ref_name }}