Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto deploy on version changes #40

Merged
merged 4 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 63 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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 }}
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
22 changes: 22 additions & 0 deletions scripts/ensure-package-versions-match.bb
Original file line number Diff line number Diff line change
@@ -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))