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 0d8be3b..29a0860 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -85,3 +85,37 @@ jobs: run: make lint - 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 + - 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/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 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))