diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e139486 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,48 @@ +on: [workflow_call] + +jobs: + build: + runs-on: ubuntu-22.04 + timeout-minutes: 5 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 8 + + - name: Restore local Maven repository from cache + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Validate SNAPSHOT version + env: + SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$ + if: github.ref != 'refs/heads/master' + run: | + lein pom + export VERSION=$(less pom.xml | grep "" | head -1 | cut -d ">" -f2 | cut -d "<" -f1) + echo "Version is:" $VERSION + if [[ !("$VERSION" =~ $SNAPSHOT_REGEX) ]] + then + echo "Version isn't a SNAPSHOT version:" $VERSION + exit 0 + fi + + - name: Setup linter + uses: DeLaGuardo/setup-clj-kondo@master + with: + version: '2021.06.18' + + - name: Lint + run: clj-kondo --lint src diff --git a/.github/workflows/ci_branch.yml b/.github/workflows/ci_branch.yml new file mode 100644 index 0000000..ae607e2 --- /dev/null +++ b/.github/workflows/ci_branch.yml @@ -0,0 +1,59 @@ +name: "Push CI - branches" + +on: + push: + branches-ignore: + - master + +jobs: + build: + uses: ./.github/workflows/build.yml + + test: + needs: build + uses: ./.github/workflows/test.yml + + deploy: + needs: test + runs-on: ubuntu-22.04 + timeout-minutes: 5 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 8 + + - name: Restore local Maven repository from cache + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Deploy SNAPSHOT version + env: + SNAPSHOT_REGEX: ^[0-9]{1,2}[.][0-9]{1,2}[.][0-9]{1,3}-SNAPSHOT$ + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} + CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} + run: | + git config --global user.name "github-actions-bot" + git config --global user.email "<>" + lein pom + export SNAPSHOT_VERSION=$(less pom.xml | grep "" | head -1 | cut -d ">" -f2 | cut -d "<" -f1) + echo "SNAPSHOT version is:" $SNAPSHOT_VERSION + if [[ !("$SNAPSHOT_VERSION" =~ $SNAPSHOT_REGEX) ]] + then + echo "Version isn't a SNAPSHOT version:" $SNAPSHOT_VERSION ", skipping deployment to Clojars..." + exit 1 + fi + lein deploy + echo "SNAPSHOT version:" $SNAPSHOT_VERSION"; commit: "${{github.sha}}"; successfully deployed to Clojars" diff --git a/.github/workflows/ci_master.yml b/.github/workflows/ci_master.yml index aba930a..e2f694a 100644 --- a/.github/workflows/ci_master.yml +++ b/.github/workflows/ci_master.yml @@ -7,95 +7,31 @@ on: jobs: build: - runs-on: ubuntu-20.04 - timeout-minutes: 5 - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - distribution: zulu - java-version: 8 - - - name: Restore local Maven repository from cache - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Setup linter - uses: DeLaGuardo/setup-clj-kondo@master - with: - version: '2021.06.18' - - - name: Lint - run: clj-kondo --lint src + uses: ./.github/workflows/build.yml test: needs: build - runs-on: ubuntu-20.04 - timeout-minutes: 5 - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - distribution: zulu - java-version: 8 - - - name: Restore local Maven repository from cache - uses: actions/cache@v2 - with: - path: ~/.m2/repository - key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} - restore-keys: | - ${{ runner.os }}-maven- - - - name: Generate proto files - run: lein protodeps generate - - - name: Unit tests - env: - IP_STACK_ACCESS_KEY: ${{ secrets.IP_STACK_ACCESS_KEY }} - run: lein cloverage --html --lcov --junit - - - name: Publish Unit Test Results - uses: EnricoMi/publish-unit-test-result-action@v1.19 - #if: always() - if: false - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - files: "target/coverage/junit.xml" - - - name: Coveralls - uses: coverallsapp/github-action@master - if: false - with: - path-to-lcov: "target/coverage/lcov.info" - github-token: ${{ secrets.GITHUB_TOKEN }} + uses: ./.github/workflows/test.yml deploy: needs: test - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 timeout-minutes: 5 steps: - name: Checkout - uses: actions/checkout@v2 - + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + - name: Set up JDK 8 - uses: actions/setup-java@v2 + uses: actions/setup-java@v3 with: - distribution: zulu + distribution: corretto java-version: 8 - + - name: Restore local Maven repository from cache - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} @@ -113,15 +49,19 @@ jobs: git config --global user.email "<>" git config --global push.followTags true lein pom - export VERSION=$(grep "" pom.xml | head -1 | cut -d ">" -f2 | cut -d "<" -f1) - echo "version is:" $VERSION - if [[ !("$VERSION" =~ $RELEASE_REGEX) ]] + export ORIGINAL_VERSION=$(less pom.xml | grep "" | head -1 | cut -d ">" -f2 | cut -d "<" -f1) + echo "Original version is:" $ORIGINAL_VERSION + lein change version leiningen.release/bump-version release + lein do vcs commit, install + lein pom + export RELEASE_VERSION=$(less pom.xml | grep "" | head -1 | cut -d ">" -f2 | cut -d "<" -f1) + echo "Release version is:" $RELEASE_VERSION + if [[ !("$RELEASE_VERSION" =~ $RELEASE_REGEX) ]] then - echo "Version isn't a release version:" $VERSION ", skipping deployment to Clojars..." - exit 0 + echo "Version isn't a release version:" $RELEASE_VERSION ", skipping deployment to Clojars..." + exit 1 fi lein deploy - echo "Release version:" $VERSION"; commit: "${{github.sha}}"; successfully deployed to Clojars" - export TAG_NAME="v$VERSION" - git tag -a -m "Version $VERSION" $TAG_NAME - git push origin $TAG_NAME + echo "Release version:" $RELEASE_VERSION"; commit: "${{github.sha}}"; successfully deployed to Clojars" + git tag -a $RELEASE_VERSION -m "Release version $RELEASE_VERSION" + git push origin master diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7480647 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,49 @@ +on: [workflow_call] + +jobs: + test: + runs-on: ubuntu-20.04 + timeout-minutes: 5 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + fetch-depth: 0 + + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: corretto + java-version: 8 + + - name: Restore local Maven repository from cache + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles( 'project.clj' ) }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Generate proto files + run: lein protodeps generate + + - name: Unit tests + env: + IP_STACK_ACCESS_KEY: ${{ secrets.IP_STACK_ACCESS_KEY }} + run: lein cloverage --html --lcov --junit + + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1.19 + #if: always() + if: false + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + files: "target/coverage/junit.xml" + + - name: Coveralls + uses: coverallsapp/github-action@master + if: false + with: + path-to-lcov: "target/coverage/lcov.info" + github-token: ${{ secrets.GITHUB_TOKEN }}