-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: publish: Move to release tag triggered publishing (#611)
* Move to release tag triggered publishing I still prefer my old GitHub UI triggered release. It feels much less complicated to me. But this project is part of clj-commons, and here I defer to the larger team's preference for release triggered publishing. I brought over this work from other projects, mostly rewrite-clj and pomegranate. These incude: - using neil to track/bump/store version in deps.edn - automatically including date in changelog release headers One refinement for Etaoin is avoiding the duplicate test run on Publish. The release tag triggered strategy includes a commit and tag from the person doing the publish. This commit triggers the normal Test workflow but the Publish workflow also triggers the Test workflow to ensure all is good before releasing. To avoid the duplicate test run, I've added a new `check-for-skip` job in the Test workflow to skip tests when appropriate. I'd love to skip the independent Test workflow on Publish entirely, but don't think the GitHub Actions YAML magic to do so exists. Closes #529 * merge new check-for-skip job into setup job Since the check-for-skip work needs pretty much the same setup as the setup job, merge the two and avoid the extra job. * yaml syntax * fix yaml * [publish workflow] should cause tests to be skipped A wee sanity test * [publish workflow] debug commit msg * remove println debug On a PR the commit message is the merge commit. That's not important to me, I care about behaviour on master, the branch from which we publish.
- Loading branch information
Showing
16 changed files
with
596 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: Publish | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v\d+.*' | ||
|
||
jobs: | ||
test: | ||
uses: ./.github/workflows/test.yml | ||
|
||
publish: | ||
environment: publish | ||
runs-on: ubuntu-latest | ||
needs: [test] | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Restore Clojure deps from cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: | | ||
~/.m2/repository | ||
~/.deps.clj | ||
~/.gitlibs | ||
enableCrossOsArchive: true | ||
key: cljdeps-${{ hashFiles('deps.edn', 'bb.edn') }} | ||
restore-keys: cljdeps- | ||
|
||
- name: Setup Java | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '21' | ||
|
||
- name: Install Clojure Tools | ||
uses: DeLaGuardo/[email protected] | ||
with: | ||
bb: 'latest' | ||
|
||
- name: Deploy to clojars | ||
env: | ||
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} | ||
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} | ||
run: bb -ci-clojars-deploy | ||
|
||
- name: Create GitHub Release | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: bb -ci-github-create-release | ||
|
||
- name: Inform Cljdoc | ||
run: bb -ci-cljdoc-request-build |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
(ns build-shared | ||
(:refer-clojure :exclude [test]) | ||
(:require | ||
[cognitect.test-runner :as tr])) | ||
[clojure.edn :as edn] | ||
[clojure.string :as string])) | ||
|
||
;; private fn pasted from original sources | ||
(defn- do-test | ||
[{:keys [dirs nses patterns vars includes excludes]}] | ||
(let [adapted {:dir (when (seq dirs) (set dirs)) | ||
:namespace (when (seq nses) (set nses)) | ||
:namespace-regex (when (seq patterns) (map re-pattern patterns)) | ||
:var (when (seq vars) (set vars)) | ||
:include (when (seq includes) (set includes)) | ||
:exclude (when (seq excludes) (set excludes))}] | ||
(tr/test adapted))) | ||
(defn- project-info [] | ||
(-> (edn/read-string (slurp "deps.edn")) | ||
:aliases :neil :project)) | ||
|
||
(def version-tag-prefix "v") | ||
|
||
(defn test | ||
"Reimplement test to not throw but instead exit with 1 on error." | ||
[opts] | ||
(try | ||
(let [{:keys [fail error]} (do-test opts)] | ||
(System/exit (if (zero? (+ fail error)) 0 1))) | ||
(finally | ||
;; Only called if `test` raises an exception | ||
(shutdown-agents)))) | ||
(defn lib-version [] | ||
(-> (project-info) :version)) | ||
|
||
(defn lib-artifact-name [] | ||
(-> (project-info) :name)) | ||
|
||
(defn lib-github-coords [] | ||
(-> (project-info) :github-coords)) | ||
|
||
(defn version->tag [version] | ||
(str version-tag-prefix version)) | ||
|
||
(defn tag->version [ci-tag] | ||
(and (string/starts-with? ci-tag version-tag-prefix) | ||
(string/replace-first ci-tag version-tag-prefix ""))) |
Oops, something went wrong.