Merge branch 'integration/stdnum-9-findings' #14
Workflow file for this run
This file contains hidden or 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
| name: release | |
| # Publishes to Clojars when a v* tag is pushed. The tag is the deliberate | |
| # "this is worth a release" signal; nothing publishes on ordinary commits. | |
| on: | |
| push: | |
| tags: ['v*'] | |
| workflow_dispatch: {} # manual run for testing; publishing is tag-only | |
| permissions: | |
| contents: write # create the GitHub Release | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - uses: DeLaGuardo/setup-clojure@13.6.1 | |
| with: | |
| cli: latest | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-m2-${{ hashFiles('deps.edn') }} | |
| restore-keys: ${{ runner.os }}-m2- | |
| - name: Verify tag matches build.clj version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| TAG="${GITHUB_REF_NAME#v}" | |
| PROJ=$(sed -n 's/.*def version "\([^"]*\)".*/\1/p' build.clj) | |
| echo "tag=$TAG build.clj=$PROJ" | |
| if [ "$TAG" != "$PROJ" ]; then | |
| echo "::error::tag v$TAG does not match build.clj version $PROJ" | |
| exit 1 | |
| fi | |
| - name: Verify tag matches project.clj version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| TAG="${GITHUB_REF_NAME#v}" | |
| PROJ=$(sed -n 's/.*defproject [^ ]* "\([^"]*\)".*/\1/p' project.clj) | |
| if [ -z "$PROJ" ]; then | |
| PROJ=$(sed -n 's/.*(def version "\([^"]*\)").*/\1/p' project.clj) | |
| fi | |
| echo "tag=$TAG project.clj=$PROJ" | |
| if [ -z "$PROJ" ] || [ "$TAG" != "$PROJ" ]; then | |
| echo "::error::tag v$TAG does not match project.clj version $PROJ" | |
| exit 1 | |
| fi | |
| - name: Verify README install coordinate matches version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| TAG="${GITHUB_REF_NAME#v}" | |
| LIB=$(grep -oE "net\.clojars\.[^ ')]+" build.clj | head -1) | |
| if ! grep -qF "$LIB {:mvn/version \"$TAG\"}" README.md; then | |
| echo "::error::README.md is missing install coordinate: $LIB {:mvn/version \"$TAG\"}" | |
| exit 1 | |
| fi | |
| - name: Verify doc/*.md install coordinates match version | |
| if: github.ref_type == 'tag' | |
| run: | | |
| TAG="${GITHUB_REF_NAME#v}" | |
| LIB=$(grep -oE "net\.clojars\.[^ ')]+" build.clj | head -1) | |
| rc=0 | |
| shopt -s nullglob | |
| for f in doc/*.md; do | |
| while IFS= read -r ver; do | |
| if [ "$ver" != "$TAG" ]; then | |
| echo "::error file=$f::$f pins $LIB {:mvn/version \"$ver\"}, expected \"$TAG\"" | |
| rc=1 | |
| fi | |
| done < <(grep -oE "net\.clojars\.[a-zA-Z0-9._/-]+ \{:mvn/version \"[^\"]+\"\}" "$f" | grep -F "$LIB {:mvn/version" | grep -oE '"[^"]+"' | tr -d '"') | |
| done | |
| exit $rc | |
| - name: Verify tag commit is on main | |
| if: github.ref_type == 'tag' | |
| run: | | |
| git fetch --no-tags origin main | |
| if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then | |
| echo "::error::tag $GITHUB_REF_NAME is not an ancestor of origin/main" | |
| exit 1 | |
| fi | |
| - name: Test | |
| run: clojure -M:test | |
| - name: Extract release notes from CHANGELOG | |
| if: github.ref_type == 'tag' | |
| run: | | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| PATTERN=$(printf '%s' "$VERSION" | sed 's/\./\\./g') | |
| awk -v p="$PATTERN" ' | |
| $0 ~ "^## \\[" p "\\]" {found=1; next} | |
| found && /^## / {exit} | |
| found {print} | |
| ' CHANGELOG.md > release-notes.md | |
| if [ ! -s release-notes.md ]; then | |
| echo "::error::CHANGELOG.md has no section for $VERSION" | |
| exit 1 | |
| fi | |
| cat release-notes.md | |
| - name: Deploy to Clojars | |
| if: github.ref_type == 'tag' | |
| env: | |
| CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} | |
| CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} | |
| run: clojure -T:build deploy | |
| - name: Create GitHub Release | |
| if: github.ref_type == 'tag' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| body_path: release-notes.md | |
| generate_release_notes: true |