Clojure CI #237
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
# Testing | |
name: Clojure CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
create: | |
tags: | |
- v* | |
jobs: | |
env: | |
runs-on: ubuntu-latest | |
steps: | |
- run: env | |
test: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, windows-latest, macOS-latest ] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setting up Clojure and Leiningen | |
uses: DeLaGuardo/setup-clojure@master | |
with: | |
lein: 2.9.5 | |
- name: Cache local Maven repository | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/project.clj') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Install Clojure dependencies | |
run: lein deps | |
- name: Run tests | |
run: lein with-profile test cloverage --runner :eftest --codecov | |
- if: matrix.os == 'ubuntu-latest' | |
name: Upload code coverage to Codecov | |
uses: codecov/codecov-action@v1 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: ./target/coverage/codecov.json | |
flags: unittests | |
name: epsilon-clj-unit | |
fail_ci_if_error: true | |
verbose: true | |
deploy: | |
runs-on: ubuntu-latest | |
needs: test | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Cache local Maven repository | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/project.clj') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Setting up Clojure and Leiningen | |
uses: DeLaGuardo/setup-clojure@master | |
with: | |
lein: 2.9.5 | |
- name: Install Clojure dependencies | |
run: lein deps | |
- name: Setting up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.x | |
- name: Cache Pip | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Python packages | |
run: pip install | |
- name: Setting git local config | |
run: | | |
git config user.name "${{ secrets.GIT_NAME }}" | |
git config user.email "${{ secrets.GIT_EMAIl }}" | |
- name: Get the version | |
id: get_version | |
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Build Uberjar | |
run: lein uberjar | |
- name: Install Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.6 | |
bundler-cache: true | |
- name: Install GitHub Changelog Generator | |
run: gem install github_changelog_generator | |
- name: Generate Changelog | |
run: | | |
github_changelog_generator \ | |
-u aratare-jp \ | |
-p epsilon-clj \ | |
--token ${{ secrets.GITHUB_TOKEN }} \ | |
--no-issues \ | |
--no-issues-wo-labels \ | |
--pull-requests \ | |
--pr-wo-labels | |
- name: Get Changelog Entry | |
id: changelog_reader | |
uses: mindsers/changelog-reader-action@v2 | |
with: | |
version: ${{ steps.get_version.outputs.VERSION }} | |
path: ./CHANGELOG.md | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.get_version.outputs.VERSION }} | |
release_name: Release ${{ steps.get_version.outputs.VERSION }} | |
draft: false | |
prerelease: false | |
body: ${{ steps.changelog_reader.outputs.changes }} | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/uberjar/epsilon-${{ steps.get_version.outputs.VERSION }}-standalone.jar | |
asset_name: epsilon-${{ steps.get_version.outputs.VERSION }}-standalone.jar | |
asset_content_type: application/java-archive | |
- name: Importing GPG | |
id: import_gpg | |
uses: crazy-max/ghaction-import-gpg@v3 | |
with: | |
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.GPG_PASSPHRASE }} | |
- name: Cache Clojar credentials | |
id: clojar_creds_cache | |
uses: actions/cache@v2 | |
with: | |
path: $LEIN_HOME/credentials.clj.gpg | |
key: ${{ runner.os }}-clojar-creds | |
- name: Setting up Clojar credentials | |
if: steps.clojar_creds_cache.cache-hit != 'true' | |
run: | | |
touch $LEIN_HOME/credentials.clj | |
echo "{#\"https://repo.clojars.org\" {:username \"${{ secrets.LEIN_DEPLOY_USERNAME }}\" :password \"${{ secrets.LEIN_DEPLOY_PASSWORD }}\"}}" > $LEIN_HOME/credentials.clj | |
gpg --output $LEIN_HOME/credentials.clj.gpg --sign $LEIN_HOME/credentials.clj | |
rm $LEIN_HOME/credentials.clj | |
- name: Deploying to Clojars | |
run: lein deploy clojars | |
- name: Upload MKDocs | |
run: mike deploy -p --update-aliases ${{ steps.get_version.outputs.VERSION }} latest |