|
| 1 | +name: "CI - Pull Requests" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + push: |
| 8 | + branches-ignore: |
| 9 | + - master |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 5 |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Set up JDK 8 |
| 20 | + uses: actions/setup-java@v4 |
| 21 | + with: |
| 22 | + distribution: zulu |
| 23 | + java-version: 8 |
| 24 | + |
| 25 | + - name: Restore local Maven repository from cache |
| 26 | + uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: ~/.m2/repository |
| 29 | + key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-maven- |
| 32 | + |
| 33 | + - name: Setup linter |
| 34 | + uses: DeLaGuardo/setup-clj-kondo@master |
| 35 | + with: |
| 36 | + version: '2025.07.28' |
| 37 | + |
| 38 | + - name: Lint |
| 39 | + run: clj-kondo --lint src test |
| 40 | + |
| 41 | + test: |
| 42 | + needs: build |
| 43 | + runs-on: ubuntu-latest |
| 44 | + timeout-minutes: 5 |
| 45 | + steps: |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Set up JDK 8 |
| 50 | + uses: actions/setup-java@v4 |
| 51 | + with: |
| 52 | + distribution: zulu |
| 53 | + java-version: 8 |
| 54 | + |
| 55 | + - name: Restore local Maven repository from cache |
| 56 | + uses: actions/cache@v4 |
| 57 | + with: |
| 58 | + path: ~/.m2/repository |
| 59 | + key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} |
| 60 | + restore-keys: | |
| 61 | + ${{ runner.os }}-maven- |
| 62 | +
|
| 63 | + - name: Unit tests |
| 64 | + env: |
| 65 | + IP_STACK_ACCESS_KEY: ${{ secrets.IP_STACK_ACCESS_KEY }} |
| 66 | + run: lein test |
| 67 | + |
| 68 | + deploy-snapshot: |
| 69 | + needs: test |
| 70 | + runs-on: ubuntu-latest |
| 71 | + timeout-minutes: 5 |
| 72 | + # Only deploy snapshots for pushes to non-master branches (not PRs) |
| 73 | + if: github.event_name == 'push' && github.ref != 'refs/heads/master' |
| 74 | + steps: |
| 75 | + - name: Checkout |
| 76 | + uses: actions/checkout@v4 |
| 77 | + |
| 78 | + - name: Set up JDK 8 |
| 79 | + uses: actions/setup-java@v4 |
| 80 | + with: |
| 81 | + distribution: zulu |
| 82 | + java-version: 8 |
| 83 | + |
| 84 | + - name: Restore local Maven repository from cache |
| 85 | + uses: actions/cache@v4 |
| 86 | + with: |
| 87 | + path: ~/.m2/repository |
| 88 | + key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} |
| 89 | + restore-keys: | |
| 90 | + ${{ runner.os }}-maven- |
| 91 | +
|
| 92 | + - name: Deploy SNAPSHOT version |
| 93 | + env: |
| 94 | + SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$ |
| 95 | + CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} |
| 96 | + CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} |
| 97 | + run: | |
| 98 | + git config --global user.name "github-actions-bot" |
| 99 | + git config --global user.email "<>" |
| 100 | + lein pom |
| 101 | + export VERSION=$(grep "<version>" pom.xml | head -1 | cut -d ">" -f2 | cut -d "<" -f1) |
| 102 | + echo "version is:" $VERSION |
| 103 | + if [[ !("$VERSION" =~ $SNAPSHOT_REGEX) ]] |
| 104 | + then |
| 105 | + echo "Version isn't a SNAPSHOT version:" $VERSION ", skipping deployment to Clojars..." |
| 106 | + exit 0 |
| 107 | + fi |
| 108 | + lein deploy |
| 109 | + echo "SNAPSHOT version:" $VERSION"; commit: "${{github.sha}}"; branch: "${{github.ref_name}}"; successfully deployed to Clojars" |
0 commit comments