From 8ed4d3ed7554b3fa788c0157a43c4fba7975116c Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sun, 25 Feb 2024 17:03:55 +0300 Subject: [PATCH] init sdk --- .github/dependabot.yml | 12 +++++++ .github/workflows/builder.yml | 60 +++++++++++++++++++++++++++++++++ .github/workflows/changelog.yml | 14 ++++++++ .github/workflows/publish.yml | 23 +++++++++++++ .gitignore | 3 +- Makefile | 3 ++ config.yaml | 4 +++ package-lock.json | 13 +++++++ package.json | 17 ++++++++++ 9 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/builder.yml create mode 100644 .github/workflows/changelog.yml create mode 100644 .github/workflows/publish.yml create mode 100644 Makefile create mode 100644 config.yaml create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..e97d08e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml new file mode 100644 index 0000000..b4eecf6 --- /dev/null +++ b/.github/workflows/builder.yml @@ -0,0 +1,60 @@ +name: builder + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + sdk: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Generate SDK + uses: openapi-generators/openapitools-generator-action@v1 + with: + generator: javascript + openapi-url: https://raw.githubusercontent.com/bavix/gripmock-openapi/master/api.yaml + command-args: -o . --package-name gripmock-sdk-js -c config.yaml + + - name: "Check if build has changed" + if: success() + id: has-changes + run: | + echo "stdout<> $GITHUB_OUTPUT + echo "$(git diff --stat)" >> $GITHUB_OUTPUT + echo 'EOF' >> $GITHUB_OUTPUT + + - name: "git add --all" + run: git add --all + + - name: Import GPG key + if: ${{ steps.has-changes.outputs.stdout }} + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_BOT }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + fingerprint: ${{ secrets.GPG_FINGERPRINT }} + git_config_global: true + git_user_signingkey: true + git_commit_gpgsign: true + git_committer_name: Github bot + git_committer_email: bot@babichev.net + + - name: "Commit files" + if: ${{ steps.has-changes.outputs.stdout }} + env: + GH_TOKEN: ${{ secrets.BOT_TOKEN }} + run: | + gh pr checkout ${{ github.event.pull_request.number }} + git commit -S -m "sdk generated" -a + + - name: "Push changes" + if: ${{ steps.has-changes.outputs.stdout }} + env: + GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} + run: git push -u origin HEAD diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..11c615e --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,14 @@ +name: update changelog + +on: + release: + types: [released] + +permissions: {} + +jobs: + changelog: + permissions: + contents: write + secrets: inherit + uses: bavix/.github/.github/workflows/changelog.yml@0.2.3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..4d3b90b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,23 @@ +name: Publish package to GitHub Packages +on: + release: + types: [published] +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + # Setup .npmrc file to publish to GitHub Packages + - uses: actions/setup-node@v3 + with: + node-version: '21.x' + registry-url: 'https://npm.pkg.github.com' + # Defaults to the user or organization that owns the workflow file + scope: '@bavix' + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index c6bba59..49f6465 100644 --- a/.gitignore +++ b/.gitignore @@ -89,7 +89,6 @@ out # Nuxt.js build / generate output .nuxt -dist # Gatsby files .cache/ @@ -128,3 +127,5 @@ dist .yarn/build-state.yml .yarn/install-state.gz .pnp.* + +.idea/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bbe0c5c --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +gen-client: + # https://github.com/OpenAPITools/openapi-generator + openapi-generator generate -i https://raw.githubusercontent.com/bavix/gripmock-openapi/master/api.yaml -g javascript -o ./generated/ diff --git a/config.yaml b/config.yaml new file mode 100644 index 0000000..e821c13 --- /dev/null +++ b/config.yaml @@ -0,0 +1,4 @@ +additionalProperties: + projectName: gripmock-sdk-js + projectVersion: 2.4.0 + licenseName: MIT \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..61563b4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "gripmock-sdk-js", + "version": "2.4.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "gripmock-sdk-js", + "version": "2.4.0", + "license": "MIT" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..ecf2395 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "gripmock-sdk-js", + "version": "2.4.0", + "type": "module", + "description": "GripMock SDK.", + "private": true, + "repository": { + "type": "git", + "url": "github.com/bavix/gripmock-sdk-js" + }, + "keywords": [ + "gripmock", + "sdk" + ], + "author": "Maksim Babichev", + "license": "MIT" +}