From 25d8f745872d2c4f114dd3313480a05716cd3814 Mon Sep 17 00:00:00 2001 From: giangndm <45644921+giangndm@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:20:09 +0700 Subject: [PATCH] ci: add goole release-please and github action (#24) --- .github/workflows/release-please.yml | 108 ++++++++++++++++++++++++++ .release-please-manifest.json | 5 ++ packages/sdk-core/package.json | 4 +- packages/sdk-react-hooks/package.json | 4 +- packages/sdk-react-ui/package.json | 4 +- release-please-config.json | 24 ++++++ 6 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/release-please.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..672fe75 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,108 @@ +on: + push: + branches: + - main + +concurrency: + group: "release-${{ github.ref }}" + cancel-in-progress: true + +permissions: + contents: write + pull-requests: write + +name: Run Release Please +jobs: + release-please: + runs-on: ubuntu-latest + outputs: + sdk-core--tag_name: ${{ steps.release.outputs['packages/sdk-core--tag_name']}} + sdk-core--release_created: ${{ steps.release.outputs['packages/sdk-core--release_created']}} + sdk-react-hooks--tag_name: ${{ steps.release.outputs['packages/sdk-react-hooks--tag_name']}} + sdk-react-hooks--release_created: ${{ steps.release.outputs['packages/sdk-react-hooks--release_created']}} + sdk-react-ui--tag_name: ${{ steps.release.outputs['packages/sdk-react-ui--tag_name']}} + sdk-react-ui--release_created: ${{ steps.release.outputs['packages/sdk-react-ui--release_created']}} + steps: + - uses: googleapis/release-please-action@v4 + id: release + with: + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + token: ${{secrets.GITHUB_TOKEN}} + - name: Print release outputs for debugging + continue-on-error: true + run: | + echo "Release outputs:" + echo "${{ toJson(steps.release.outputs) }}" + + release-sdk-core: + needs: release-please + if: ${{needs.release-please.outputs.sdk-core--release_created}} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + - uses: pnpm/action-setup@v2 + with: + version: 8 + - name: Build Packages + working-directory: ./packages/sdk-core + run: | + pnpm install + pnpm build + - name: Publish to NPM + working-directory: ./packages/sdk-core + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + run: pnpm publish + + release-sdk-react-hooks: + needs: release-please + if: ${{needs.release-please.outputs.sdk-react-hooks--release_created}} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + - uses: pnpm/action-setup@v2 + with: + version: 8 + - name: Build Packages + working-directory: ./packages/sdk-react-hooks + run: | + pnpm install + pnpm build + - name: Publish to NPM + working-directory: ./packages/sdk-react-hooks + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + run: pnpm publish + + release-sdk-react-ui: + needs: release-please + if: ${{needs.release-please.outputs.sdk-react-ui--release_created}} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: 'https://registry.npmjs.org' + - uses: pnpm/action-setup@v2 + with: + version: 8 + - name: Build Packages + working-directory: ./packages/sdk-react-ui + run: | + pnpm install + pnpm build + - name: Publish to NPM + working-directory: ./packages/sdk-react-ui + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + run: pnpm publish diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..828f2cf --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,5 @@ +{ + "packages/sdk-core": "1.0.0-alpha.5", + "packages/sdk-react-hooks": "1.0.0-alpha.6", + "packages/sdk-react-ui": "1.0.0-alpha.5" +} \ No newline at end of file diff --git a/packages/sdk-core/package.json b/packages/sdk-core/package.json index 865458a..94f68db 100644 --- a/packages/sdk-core/package.json +++ b/packages/sdk-core/package.json @@ -1,6 +1,6 @@ { "name": "@atm0s-media-sdk/core", - "version": "1.0.0-alpha.4", + "version": "1.0.0-alpha.5", "main": "./dist/lib.js", "module": "./dist/lib.mjs", "types": "./dist/lib.d.ts", @@ -27,4 +27,4 @@ "build": "tsup src/lib.ts --format cjs,esm --dts", "dev": "tsup src/lib.ts --format cjs,esm --dts --watch" } -} +} \ No newline at end of file diff --git a/packages/sdk-react-hooks/package.json b/packages/sdk-react-hooks/package.json index e527a18..d718e37 100644 --- a/packages/sdk-react-hooks/package.json +++ b/packages/sdk-react-hooks/package.json @@ -1,6 +1,6 @@ { "name": "@atm0s-media-sdk/react-hooks", - "version": "1.0.0-alpha.5", + "version": "1.0.0-alpha.6", "main": "./dist/lib.js", "module": "./dist/lib.mjs", "types": "./dist/lib.d.ts", @@ -31,4 +31,4 @@ "build": "tsup src/lib.tsx --format cjs,esm --dts", "dev": "tsup src/lib.tsx --format cjs,esm --dts --watch" } -} +} \ No newline at end of file diff --git a/packages/sdk-react-ui/package.json b/packages/sdk-react-ui/package.json index 6aa3553..d41a71b 100644 --- a/packages/sdk-react-ui/package.json +++ b/packages/sdk-react-ui/package.json @@ -1,6 +1,6 @@ { "name": "@atm0s-media-sdk/react-ui", - "version": "1.0.0-alpha.4", + "version": "1.0.0-alpha.5", "main": "./dist/lib.js", "module": "./dist/lib.mjs", "types": "./dist/lib.d.ts", @@ -35,4 +35,4 @@ "dev": "tsup src/lib.tsx --format cjs,esm --dts --watch", "generate:component": "turbo gen react-component" } -} +} \ No newline at end of file diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..854cbd3 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,24 @@ +{ + "include-component-in-tag": true, + "tag-separator": "@", + "release-type": "node", + "separate-pull-requests": true, + "plugins": [ + { + "type": "node-workspace", + "updatePeerDependencies": true + } + ], + "packages": { + "packages/sdk-core": { + "package-name": "@atm0s-media-sdk/core" + }, + "packages/sdk-react-hooks": { + "package-name": "@atm0s-media-sdk/react-hooks" + }, + "packages/sdk-react-ui": { + "package-name": "@atm0s-media-sdk/react-ui" + } + }, + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json" +} \ No newline at end of file