From 639b4b6f77802a0bd972d2da55ba62499a6ee96a Mon Sep 17 00:00:00 2001 From: Joshua Smock Date: Fri, 16 Jun 2023 17:23:57 +0200 Subject: [PATCH 1/4] Create a script to check that the package versions match - Run this script in a CI job --- .github/workflows/tests.yml | 17 +++++++++++++++++ scripts/ensure-package-versions-match.bb | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 scripts/ensure-package-versions-match.bb diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0d8be3b..27f7785 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -85,3 +85,20 @@ jobs: run: make lint - name: Run JS tests run: make test-ci + + ensure-package-versions-match: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: 'corretto' + java-version: '17' + - name: Setup Clojure + uses: DeLaGuardo/setup-clojure@9.5 + with: + cli: 1.11.1.1224 + bb: 1.3.181 + - name: Run ensure-package-versions-match script + run: scripts/ensure-package-versions-match.bb diff --git a/scripts/ensure-package-versions-match.bb b/scripts/ensure-package-versions-match.bb new file mode 100755 index 0000000..166d51f --- /dev/null +++ b/scripts/ensure-package-versions-match.bb @@ -0,0 +1,22 @@ +#!/usr/bin/env bb + +(require '[babashka.fs :as fs] + '[cheshire.core :as json] + '[clojure.edn :as edn]) + +(def cljest-version (-> (fs/file "./cljest/build.edn") + slurp + edn/read-string + :version)) +(def jest-preset-cljest-version (-> (fs/file "./jest-preset-cljest/package.json") + slurp + (json/parse-string true) + :version)) + +;; TODO: properly handle our semantic versioning expectations. If we release an alpha +;; package (e.g. 1.2.0-alpha1) and the other package is 1.1.1, this shouldn't fail. +(when-not (= cljest-version jest-preset-cljest-version) + (prn (format "cljest (%s) and jest-preset-cljest (%s) versions do not match." + cljest-version + jest-preset-cljest-version)) + (System/exit 1)) From f213594c7168ec98973cd4fd0fd050c932df30d5 Mon Sep 17 00:00:00 2001 From: Joshua Smock Date: Fri, 16 Jun 2023 17:30:05 +0200 Subject: [PATCH 2/4] test running only when certain files change --- .github/workflows/tests.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 27f7785..b363d65 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -86,7 +86,25 @@ jobs: - name: Run JS tests run: make test-ci + check-version-bumps: + runs-on: ubuntu-latest + outputs: + changed: ${{ steps.versions-bumped.outputs.any_changed }} + steps: + - uses: actions/checkout@v3 + - name: Check if versions bumped + id: versions-bumped + uses: tj-actions/changed-files@v36.3.0 + with: + files: | + cljest/build.edn + jest-preset-cljest/package.json + + ensure-package-versions-match: + needs: check-version-bumps + if: needs.check-version-bumps.outputs.changed == 'true' + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From edca2a8bea6b0a0df439e8933ac4fd13b3074c8b Mon Sep 17 00:00:00 2001 From: Joshua Smock Date: Fri, 16 Jun 2023 17:55:32 +0200 Subject: [PATCH 3/4] Add deploy CI workflow --- .github/workflows/deploy.yml | 63 ++++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 1 - 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..feb7e57 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,63 @@ +name: Deploy packages +on: + push: + branches: + - master + workflow_dispatch: + +jobs: + check-version-bumps: + runs-on: ubuntu-latest + outputs: + changed: ${{ steps.versions-bumped.outputs.any_changed }} + steps: + - uses: actions/checkout@v3 + - name: Check if versions bumped + id: versions-bumped + uses: tj-actions/changed-files@v36.3.0 + with: + files: | + cljest/build.edn + jest-preset-cljest/package.json + + deploy-cljest: + needs: check-version-bumps + if: needs.check-version-bumps.outputs.changed == 'true' + + runs-on: ubuntu-latest + defaults: + run: + working-directory: cljest + steps: + - uses: actions/checkout@v3 + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: 'corretto' + java-version: '17' + - name: Setup Clojure + uses: DeLaGuardo/setup-clojure@9.5 + with: + cli: 1.11.1.1224 + - name: Deploy cljest + run: make publish-to-clojars + env: + CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} + CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} + + deploy-jest-preset-cljest: + needs: check-version-bumps + if: needs.check-version-bumps.outputs.changed == 'true' + + runs-on: ubuntu-latest + defaults: + run: + working-directory: jest-preset-cljest + steps: + - uses: actions/checkout@v3 + - name: Deploy jest-preset-cljest + run: | + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + npm publish + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b363d65..29a0860 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -100,7 +100,6 @@ jobs: cljest/build.edn jest-preset-cljest/package.json - ensure-package-versions-match: needs: check-version-bumps if: needs.check-version-bumps.outputs.changed == 'true' From 4c813847a1b0cba517f43d26d0f66982aaec2fbb Mon Sep 17 00:00:00 2001 From: Joshua Smock Date: Fri, 16 Jun 2023 17:59:24 +0200 Subject: [PATCH 4/4] Update changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 3275c51..3081574 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ - [Build using `clojure.tools.build` instead of `applied-science/deps-library`.](https://github.com/pitch-io/cljest/pull/38) - [Migrate from `applied-science/deps-library` to `deps-deploy` for Clojars deployment.](https://github.com/pitch-io/cljest/pull/38) +- [Check that the versions match expectations and automatically merge when they bump.](https://github.com/pitch-io/cljest/pull/40) # 1.1.0