From 6a6cff62827fb5b347986c0669e4845f93784ad4 Mon Sep 17 00:00:00 2001 From: alina sireneva Date: Mon, 2 Dec 2024 08:42:18 +0300 Subject: [PATCH] ci: migrate to fuman --- .github/workflows/release.yaml | 60 +++++++---------------- .github/workflows/test.yaml | 87 +++++++++++++--------------------- 2 files changed, 48 insertions(+), 99 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2e2c5a3f..f1b1ebf7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -3,16 +3,13 @@ name: Run release on: workflow_dispatch: inputs: - packages: - description: 'Packages to release (comma separated names, `all` or `updated`)' - required: true - default: 'updated' kind: description: 'Release kind (major, minor, patch)' required: true - default: 'patch' + default: 'auto' type: choice options: + - auto - major - minor - patch @@ -27,7 +24,7 @@ jobs: permissions: contents: write packages: write - id-token: write # The OIDC ID token is used for authentication with JSR. + id-token: write steps: - name: Checkout repository uses: actions/checkout@v3 @@ -36,49 +33,24 @@ jobs: token: ${{ secrets.BOT_PAT }} - if: ${{ github.event.inputs.branch != 'master' }} run: git checkout ${{ github.event.inputs.branch }} + - uses: ./.github/actions/init + - uses: denoland/setup-deno@v1 + with: + deno-version: '2.0' + - name: Initialize configs run: | git config user.name "mtcute-bot" git config user.email mtcute-bot@tei.su - npm config set //registry.npmjs.org/:_authToken ${{ secrets.NPM_TOKEN }} - - name: Verify NPM token - run: npm whoami - - name: Find packages to publish - id: find - run: node scripts/find-updated-packages.js ${{ inputs.kind }} ${{ inputs.packages }} - - name: Generate changelog - id: changelog - run: node scripts/generate-changelog.js ${{ steps.find.outputs.modified }} - - name: Bump versions - id: bump - run: node scripts/bump-version.js ${{ inputs.kind }} ${{ steps.find.outputs.modified }} - - name: Build packages and publish to NPM - id: build + + - name: Run release env: - GH_RELEASE: 1 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: node scripts/publish.js ${{ steps.find.outputs.modified }} - - uses: denoland/setup-deno@v1 - with: - deno-version: '1.46.3' - - name: Build packages and publish to JSR - continue-on-error: true # temporary - env: - JSR: 1 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: node scripts/publish.js ${{ steps.find.outputs.modified }} - - name: Commit version bumps run: | - git commit -am "v${{ steps.bump.outputs.version }}" - git push - - name: GitHub Release - uses: ncipollo/release-action@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - tag: v${{ steps.bump.outputs.version }} - name: v${{ steps.bump.outputs.version }} - artifacts: ${{ steps.build.outputs.tarballs }} - body: ${{ steps.changelog.outputs.changelog }} - draft: false - prerelease: false + fuman-build release \ + --kind=${{ github.event.inputs.kind }} \ + --with-npm \ + --npm-token=${{ secrets.NPM_TOKEN }} \ + --with-jsr \ + --with-github-release diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 233fbdf8..7442fcf3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -36,12 +36,6 @@ jobs: node-version: [18.x, 20.x, 22.x] steps: - uses: actions/checkout@v4 - - name: Fetch fuman - uses: actions/checkout@v4 - with: - repository: teidesu/fuman - path: private/fuman - token: ${{ secrets.BOT_PAT }} - uses: ./.github/actions/init with: node-version: ${{ matrix.node-version }} @@ -59,12 +53,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Fetch fuman - uses: actions/checkout@v4 - with: - repository: teidesu/fuman - path: private/fuman - token: ${{ secrets.BOT_PAT }} - uses: ./.github/actions/init - uses: oven-sh/setup-bun@v1 with: @@ -78,12 +66,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Fetch fuman - uses: actions/checkout@v4 - with: - repository: teidesu/fuman - path: private/fuman - token: ${{ secrets.BOT_PAT }} - uses: ./.github/actions/init - uses: denoland/setup-deno@v1 with: @@ -101,12 +83,6 @@ jobs: browser: [chromium, firefox] steps: - uses: actions/checkout@v4 - - name: Fetch fuman - uses: actions/checkout@v4 - with: - repository: teidesu/fuman - path: private/fuman - token: ${{ secrets.BOT_PAT }} - name: 'Build Docker image' run: docker build . -f .github/Dockerfile.test-web --build-arg BROWSER=${{ matrix.browser }} -t mtcute/test-web - name: 'Run tests' @@ -126,42 +102,43 @@ jobs: actions: write steps: - uses: actions/checkout@v4 - - name: Fetch fuman - uses: actions/checkout@v4 - with: - repository: teidesu/fuman - path: private/fuman - token: ${{ secrets.BOT_PAT }} - name: Run end-to-end tests env: API_ID: ${{ secrets.TELEGRAM_API_ID }} API_HASH: ${{ secrets.TELEGRAM_API_HASH }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: cd e2e/node && ./cli.sh ci - - name: Publish to canary NPM - if: github.repository == 'mtcute/mtcute' # do not run on forks - continue-on-error: true + e2e-deno: + runs-on: ubuntu-latest + needs: [lint, test-node, test-web, test-bun, test-deno] + permissions: + contents: read + actions: write + steps: + - uses: actions/checkout@v4 + - name: Run end-to-end tests under Deno env: - NPM_TOKEN: ${{ secrets.CANARY_NPM_TOKEN }} + API_ID: ${{ secrets.TELEGRAM_API_ID }} + API_HASH: ${{ secrets.TELEGRAM_API_HASH }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REGISTRY: 'https://npm.tei.su' - run: cd e2e/node && ./cli.sh ci-publish - # e2e-deno: - # runs-on: ubuntu-latest - # needs: [lint, test-node, test-web, test-bun, test-deno] - # permissions: - # contents: read - # actions: write - # steps: - # - uses: actions/checkout@v4 - # - name: Run end-to-end tests under Deno - # env: - # API_ID: ${{ secrets.TELEGRAM_API_ID }} - # API_HASH: ${{ secrets.TELEGRAM_API_HASH }} - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # uses: nick-fields/retry@v2 - # # thanks docker networking very cool - # with: - # max_attempts: 3 - # timeout_minutes: 30 - # command: cd e2e/deno && ./cli.sh ci + uses: nick-fields/retry@v2 + # thanks docker networking very cool + with: + max_attempts: 3 + timeout_minutes: 30 + command: cd e2e/deno && ./cli.sh ci + + cr: + needs: + - e2e-deno + - e2e + runs-on: ubuntu-latest + # dont run on forks or release commits + if: github.repository == 'mtcute/mtcute' && github.actor != 'mtcute-bot' + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/init + - name: 'publish to pkg.pr.new' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: fuman-build cr \ No newline at end of file