From b7d5e76c50eb7ac114ca03726f154726d342dc39 Mon Sep 17 00:00:00 2001 From: Kaustubh Kumar Date: Mon, 26 Feb 2024 18:38:15 +0530 Subject: [PATCH] ci: add more automation --- .github/workflows/alpha-release.yml | 79 ++++++++++++++++++++++++ .github/workflows/sync-alpha-to-main.yml | 22 +++++++ 2 files changed, 101 insertions(+) create mode 100644 .github/workflows/alpha-release.yml create mode 100644 .github/workflows/sync-alpha-to-main.yml diff --git a/.github/workflows/alpha-release.yml b/.github/workflows/alpha-release.yml new file mode 100644 index 0000000000..bbe49b9924 --- /dev/null +++ b/.github/workflows/alpha-release.yml @@ -0,0 +1,79 @@ +name: Publish and deploy alpha versions + +on: + push: + branches: + - publish-alpha + +jobs: + bump_versions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Configure Git user + run: | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + + - name: Install packages + run: yarn install --frozen-lockfile + + - name: Update versions + env: + BUMP: ${{ github.event.inputs.versionBump }} + run: | + yarn global add lerna@5 + lerna -v + echo $(lerna version $BUMP --no-git-tag-version --exact --yes --no-private) + lerna add @100mslive/hms-video-store --peer --scope=@100mslive/hms-virtual-background --exact + lerna add @100mslive/roomkit-react --scope=prebuilt-react-integration --exact + + - name: Commit and push changes + run: | + git add . + git commit -m "build: update versions for release" + git push origin HEAD:publish-alpha + + publish_packages: + runs-on: ubuntu-latest + needs: bump_versions + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 18 + registry-url: https://registry.npmjs.org/ + + - name: Install packages + run: yarn install + + - name: Test + run: yarn test + + - name: Configure Git user + run: | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + + # from-package will publish whatever version is present in each package's package.json + # it will not publish if the version is already published in npm + - name: Publish + run: yarn lerna:publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + PUBLISH_FLAG: alpha + + # Delay to wait for the publish to finish + - name: Delay for 2 minutes + run: sleep 120 + + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@v3 + with: + token: ${{ secrets.PAT }} + repository: 100mslive/100ms-links + event-type: alpha-publish + \ No newline at end of file diff --git a/.github/workflows/sync-alpha-to-main.yml b/.github/workflows/sync-alpha-to-main.yml new file mode 100644 index 0000000000..bc5039c0b7 --- /dev/null +++ b/.github/workflows/sync-alpha-to-main.yml @@ -0,0 +1,22 @@ +name: Update publish-alpha +on: + pull_request: + types: [closed] + branches: + - main + +jobs: + pull-request: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: pull-request + uses: repo-sync/pull-request@v2 + if: github.event.pull_request.merged == true + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + source_branch: 'main' + destination_branch: 'publish-alpha' + pr_title: 'Update publish-alpha' + pr_body: ':robot: Automated PR from main to publish-alpha' + pr_label: 'auto-pr'