From 772a411b797d3fe558f5c63873f4ebd343bc4574 Mon Sep 17 00:00:00 2001 From: Estriga97 Date: Tue, 24 Oct 2023 18:02:41 +0100 Subject: [PATCH] added changesets --- .changeset/README.md | 16 +++++ .changeset/config.json | 11 ++++ .../install_and_cache_dependencies/action.yml | 38 ++++++++++++ .github/workflows/release.yml | 58 +++++++++++++++++++ .github/workflows/unit_tests.yml | 27 +++++++++ package.json | 1 + 6 files changed, 151 insertions(+) create mode 100644 .changeset/README.md create mode 100644 .changeset/config.json create mode 100644 .github/actions/install_and_cache_dependencies/action.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/unit_tests.yml diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 0000000..970b732 --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,16 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) + +## Adding a changeset + +Use `npx changeset` to add a changeset. Pick the patch type that matches the changes you made (we use semantic versioning), and write a summary. This will be logged in a changeset file that you must commit to git. A recommended git message is of the form "docs(changeset): ". + +The changeset file is just markdown (after the frontmatter) and will be used to generate a changelog when we release. + +Some changes do not (or should not) require a version bump. In order to log a changeset for such a change, use `npx changeset --blank` instead. \ No newline at end of file diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 0000000..77b0419 --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@2.3.1/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "public", + "baseBranch": "master", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/.github/actions/install_and_cache_dependencies/action.yml b/.github/actions/install_and_cache_dependencies/action.yml new file mode 100644 index 0000000..23972c1 --- /dev/null +++ b/.github/actions/install_and_cache_dependencies/action.yml @@ -0,0 +1,38 @@ +name: Install dependencies +author: Johannes L. Borresen +runs: + using: composite + steps: + - name: Setup Node.js + + uses: actions/setup-node@v3.8.1 + with: + node-version: "19" + + # The steps that have been commented out are specific for caching the PNPM + # store (central dependency cache) between builds. It has been kept in case + # you want to use it. + + # - name: Setup pnpm + # uses: pnpm/action-setup@v2.4.0 + # with: + # run_install: false + + # - name: Detect PNPM store directory + # shell: bash + # run: | + # echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + # - name: Setup cache + # uses: actions/cache@v3 + # with: + # path: ${{ env.STORE_PATH }} + # key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + # restore-keys: | + # ${{ runner.os }}-pnpm-store- + + # Note: if caching is re-introduced, avoid use of `npm ci` as this command + # removes node_modules before running. + - name: Install dependencies + shell: bash + run: npm i \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..0335e0e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +# This file's workflow invokes changesets to generate and publish a release. +# If pushing to the master branch, the changesets action is used to maintain a +# release-specific pull request, and trigger an actual release if that PR is +# merged. +# If pushing to develop, a snapshot release is published to the @develop tag +# instead. + +name: Release +on: + push: + branches: + - master + - develop + +permissions: write-all + +jobs: + # Run unit tests by calling the workflow in unit_tests.yml + unit_tests: + name: Unit tests + uses: ./.github/workflows/unit_tests.yml + + release: + name: Release + runs-on: ubuntu-latest + # needs: unit_tests # Release step will ONLY run if unit tests complete. + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup (cache, dependencies) + uses: ./.github/actions/install_and_cache_dependencies + + - name: Build + run: npm run build + + # For stable branch, use changeset action to maintain a PR and finally + # publish when appropriate. + - name: Create release (or Pull Request) + if: github.ref_name == 'master' + uses: changesets/action@v1 + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + publish: npm run release + + # Snapshot releases don't need the changeset action to put together PRs. + - name: Create snapshot release + if: github.ref_name == 'develop' + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc + npm run build + npx changeset version --snapshot develop + npx changeset publish --tag develop diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..8ae9011 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,27 @@ + +name: Unit Tests +on: + pull_request: + branches: + - develop + workflow_call: + inputs: + unused: + type: boolean + description: Unused, but it seems you must define *something* for workflow_call. + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup (cache, dependencies) + uses: ./.github/actions/install_and_cache_dependencies + + - name: Build + run: npm run build + + - name: Test + run: npm test \ No newline at end of file diff --git a/package.json b/package.json index 50894bc..744cc66 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "puppeteer-extra-plugin-stealth": "^2.11.2" }, "devDependencies": { + "@changesets/cli": "^2.26.2", "@qualweb/types": "0.7.22", "@tsconfig/recommended": "^1.0.1", "@types/node": "^17.0.19",