|
1 | 1 | name: CI
|
2 | 2 | on:
|
3 |
| - push: |
4 |
| - schedule: |
5 |
| - - cron: 13 21 * * * |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - "**" |
| 6 | + tags: |
| 7 | + - "v*.*.*" |
| 8 | + schedule: |
| 9 | + - cron: 13 21 * * * |
6 | 10 |
|
7 | 11 | jobs:
|
8 |
| - docker-build-cache: |
9 |
| - name: docker build cache |
10 |
| - runs-on: ci-cd |
11 |
| - steps: |
12 |
| - - uses: docker/setup-buildx-action@v3 |
13 |
| - with: |
14 |
| - install: true |
15 |
| - - uses: docker/build-push-action@v5 |
16 |
| - id: build |
17 |
| - with: |
18 |
| - cache-from: type=gha |
19 |
| - cache-to: type=gha,mode=max |
20 |
| - tags: fluree/server |
21 |
| - target: builder |
22 |
| - load: true |
| 12 | + docker-build-cache: |
| 13 | + name: docker build cache |
| 14 | + runs-on: ci-cd |
| 15 | + steps: |
| 16 | + - uses: docker/setup-buildx-action@v3 |
| 17 | + with: |
| 18 | + install: true |
| 19 | + - uses: docker/build-push-action@v5 |
| 20 | + id: build |
| 21 | + with: |
| 22 | + cache-from: type=gha |
| 23 | + cache-to: type=gha,mode=max |
| 24 | + tags: fluree/server |
| 25 | + target: builder |
| 26 | + load: true |
23 | 27 |
|
24 |
| - cljfmt-check: |
25 |
| - name: cljfmt check |
26 |
| - runs-on: ubuntu-latest |
27 |
| - steps: |
28 |
| - - uses: actions/checkout@v4 |
29 |
| - - uses: actions/setup-java@v4 |
30 |
| - with: |
31 |
| - distribution: 'temurin' |
32 |
| - java-version: '21' |
33 |
| - - uses: DeLaGuardo/setup-clojure@12.5 |
34 |
| - with: |
35 |
| - cli: 'latest' |
36 |
| - cljfmt: 'latest' |
37 |
| - - run: make cljfmt-check |
| 28 | + cljfmt-check: |
| 29 | + name: cljfmt check |
| 30 | + runs-on: ubuntu-latest |
| 31 | + steps: |
| 32 | + - uses: actions/checkout@v4 |
| 33 | + - uses: actions/setup-java@v4 |
| 34 | + with: |
| 35 | + distribution: "temurin" |
| 36 | + java-version: "21" |
| 37 | + - uses: DeLaGuardo/setup-clojure@12.5 |
| 38 | + with: |
| 39 | + cli: "latest" |
| 40 | + cljfmt: "latest" |
| 41 | + - run: make cljfmt-check |
38 | 42 |
|
39 |
| - clj-kondo-lint: |
40 |
| - name: clj-kondo lint |
41 |
| - runs-on: ubuntu-latest |
42 |
| - steps: |
43 |
| - - uses: actions/checkout@v4 |
44 |
| - - uses: DeLaGuardo/setup-clojure@12.5 |
45 |
| - with: |
46 |
| - cli: 'latest' |
47 |
| - clj-kondo: 'latest' |
48 |
| - - run: make clj-kondo-lint-ci |
| 43 | + clj-kondo-lint: |
| 44 | + name: clj-kondo lint |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + - uses: DeLaGuardo/setup-clojure@12.5 |
| 49 | + with: |
| 50 | + cli: "latest" |
| 51 | + clj-kondo: "latest" |
| 52 | + - run: make clj-kondo-lint-ci |
49 | 53 |
|
50 |
| - test: |
51 |
| - name: run tests |
52 |
| - needs: docker-build-cache |
53 |
| - runs-on: ci-cd |
54 |
| - steps: |
55 |
| - - uses: docker/setup-buildx-action@v3 |
56 |
| - with: |
57 |
| - install: true |
58 |
| - - uses: docker/build-push-action@v5 |
59 |
| - with: |
60 |
| - cache-from: type=gha |
61 |
| - cache-to: type=gha,mode=max |
62 |
| - tags: fluree/server |
63 |
| - target: builder |
64 |
| - load: true |
65 |
| - - name: Run tests |
66 |
| - run: docker run fluree/server make test |
| 54 | + test: |
| 55 | + name: run tests |
| 56 | + needs: docker-build-cache |
| 57 | + runs-on: ci-cd |
| 58 | + steps: |
| 59 | + - uses: docker/setup-buildx-action@v3 |
| 60 | + with: |
| 61 | + install: true |
| 62 | + - uses: docker/build-push-action@v5 |
| 63 | + with: |
| 64 | + cache-from: type=gha |
| 65 | + cache-to: type=gha,mode=max |
| 66 | + tags: fluree/server |
| 67 | + target: builder |
| 68 | + load: true |
| 69 | + - name: Run tests |
| 70 | + run: docker run fluree/server make test |
67 | 71 |
|
68 |
| - notifications: |
69 |
| - name: send notifications |
70 |
| - if: always() |
71 |
| - runs-on: ubuntu-latest |
72 |
| - needs: [test] |
73 |
| - steps: |
74 |
| - - if: github.ref == 'refs/heads/main' && failure() |
75 |
| - env: |
76 |
| - SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
77 |
| - uses: voxmedia/github-action-slack-notify-build@v2 |
78 |
| - with: |
79 |
| - channel: development |
80 |
| - status: FAILED |
81 |
| - color: danger |
| 72 | + release: |
| 73 | + name: create release |
| 74 | + if: startsWith(github.ref, 'refs/tags/v') |
| 75 | + needs: test |
| 76 | + runs-on: ubuntu-latest |
| 77 | + env: |
| 78 | + VERSION: ${{ github.ref_name }} |
| 79 | + IS_PRERELEASE: ${{ contains(github.ref_name, '-') }} |
| 80 | + steps: |
| 81 | + - uses: actions/checkout@v4 |
| 82 | + with: |
| 83 | + fetch-depth: 0 # ensure full history for branch detection |
| 84 | + |
| 85 | + - name: Log release version |
| 86 | + run: | |
| 87 | + echo "VERSION=${{ env.VERSION }}" |
| 88 | +
|
| 89 | + - name: Set up Docker |
| 90 | + uses: docker/setup-buildx-action@v3 |
| 91 | + |
| 92 | + - name: Check if commit is on main |
| 93 | + run: | |
| 94 | + git fetch origin main --depth=1 |
| 95 | + if git branch --contains $GITHUB_SHA | grep -q 'main'; then |
| 96 | + echo "IS_MAINLINE=true" >> $GITHUB_ENV |
| 97 | + else |
| 98 | + echo "IS_MAINLINE=false" >> $GITHUB_ENV |
| 99 | + fi |
| 100 | +
|
| 101 | + - name: Set tag variables |
| 102 | + id: tag_vars |
| 103 | + run: | |
| 104 | + echo "VERSION_TAG=fluree/server:${{ env.VERSION }}" >> $GITHUB_ENV |
| 105 | + if [[ "${IS_MAINLINE}" == "true" && "${{ env.IS_PRERELEASE }}" == "false" ]]; then |
| 106 | + echo "LATEST_TAG_IF_MAINLINE=fluree/server:latest" >> $GITHUB_ENV |
| 107 | + else |
| 108 | + echo "LATEST_TAG_IF_MAINLINE=" >> $GITHUB_ENV |
| 109 | + fi |
| 110 | +
|
| 111 | + - uses: docker/login-action@v3 |
| 112 | + with: |
| 113 | + username: ${{ vars.DOCKER_HUB_USER }} |
| 114 | + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} |
| 115 | + |
| 116 | + - name: Build and push Docker image |
| 117 | + uses: docker/build-push-action@v5 |
| 118 | + with: |
| 119 | + context: . |
| 120 | + push: true |
| 121 | + tags: | |
| 122 | + ${{ env.VERSION_TAG }} |
| 123 | + ${{ env.LATEST_TAG_IF_MAINLINE }} |
| 124 | + platforms: linux/amd64,linux/arm64 |
| 125 | + build-args: VERSION=${{ env.VERSION }} |
| 126 | + cache-from: type=gha |
| 127 | + cache-to: type=gha,mode=max |
| 128 | + |
| 129 | + - name: Create GitHub release |
| 130 | + uses: softprops/action-gh-release@v1 |
| 131 | + env: |
| 132 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 133 | + with: |
| 134 | + tag_name: ${{ github.ref_name }} |
| 135 | + draft: false |
| 136 | + prerelease: ${{ env.IS_PRERELEASE }} |
| 137 | + generate_release_notes: true |
| 138 | + body: | |
| 139 | + Docker image: https://hub.docker.com/r/fluree/server/tags?name=${{ github.ref_name }} |
| 140 | +
|
| 141 | + notifications: |
| 142 | + name: send notifications |
| 143 | + if: always() |
| 144 | + runs-on: ubuntu-latest |
| 145 | + needs: [test, release] |
| 146 | + steps: |
| 147 | + - if: (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) && failure() |
| 148 | + env: |
| 149 | + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |
| 150 | + uses: voxmedia/github-action-slack-notify-build@v2 |
| 151 | + with: |
| 152 | + channel: development |
| 153 | + status: FAILED |
| 154 | + color: danger |
0 commit comments