release: 1.0.1 #15
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
name: main | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
# Manual run from GitHub UI | |
workflow_dispatch: | |
# Wednesdays at 0400 | |
# schedule: | |
# - cron: '0 4 * * 3' | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
build-and-test: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java-version: [17] | |
env: | |
ENV_FILE: .env | |
# Below should be overwritten by .env | |
TORCH_VERSION: cpu | |
MODEL_NAME: hyp1231/blair-roberta-base | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Load environment variables | |
run: cat ${{ env.ENV_FILE }} >> $GITHUB_ENV | |
- name: Use Java ${{ matrix.java-version }} | |
uses: actions/setup-java@v4 | |
with: | |
java-version: ${{ matrix.java-version }} | |
cache: 'gradle' | |
distribution: 'liberica' | |
- name: Setup pdm | |
uses: pdm-project/setup-pdm@v4 | |
- name: Restore cached venv | |
id: cache-venv-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
.venv | |
key: venv-${{ runner.os }}-${{ hashFiles('pdm.lock') }} | |
restore-keys: | | |
venv-${{ runner.os }}- | |
venv- | |
- name: Install dependencies | |
run: | | |
pdm install | |
pdm install-${{ env.TORCH_VERSION }} | |
- name: Save venv to cache | |
id: cache-venv-save | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
.venv | |
key: ${{ steps.cache-venv-restore.outputs.cache-primary-key }} | |
- name: Restore cached model files | |
id: cache-model-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
data/models | |
key: models-${{ env.MODEL_NAME }} | |
- name: Download model files | |
run: make get-model | |
- name: Save model files to cache | |
id: cache-model-save | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
data/models | |
key: ${{ steps.cache-model-restore.outputs.cache-primary-key }} | |
- name: Install | |
run: make deps | |
- name: Build | |
run: make docker-build | |
- name: Test | |
run: make test-ci | |
- name: Test is release | |
if: startsWith(github.event.head_commit.message, 'release:') && github.event_name == 'push' | |
id: isRelease | |
run: | | |
echo "value=true" >> $GITHUB_OUTPUT | |
- name: Get release version string | |
if: steps.isRelease.outputs.value | |
id: getVersion | |
env: | |
MESSAGE: ${{ github.event.head_commit.message }} | |
run: | | |
VALUE=$(echo "${MESSAGE}" | sed 's/release://' | sed 's/[[:space:]]*//g') | |
echo "value=${VALUE}" >> $GITHUB_OUTPUT | |
- name: Create tag | |
if: steps.isRelease.outputs.value | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/${{ steps.getVersion.outputs.value }}", | |
sha: context.sha | |
}) | |
- name: Docker login | |
if: steps.isRelease.outputs.value | |
env: | |
GITHUB_REPOSITORY_OWNER: ${{ github.repository.owner }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: make docker-login-github | |
- name: Tag Docker build | |
if: steps.isRelease.outputs.value | |
env: | |
GITHUB_REPOSITORY_OWNER: ${{ github.repository.owner }} | |
#RELEASE_TAG: ${{ steps.getVersion.outputs.value }} | |
RELEASE_TAG: latest | |
run: make docker-tag-github | |
- name: Push Docker build to container registry | |
if: steps.isRelease.outputs.value | |
env: | |
GITHUB_REPOSITORY_OWNER: ${{ github.repository.owner }} | |
#RELEASE_TAG: ${{ steps.getVersion.outputs.value }} | |
RELEASE_TAG: latest | |
run: make docker-push-github |