Skip to content

Reorganise deploy workflow #8

Reorganise deploy workflow

Reorganise deploy workflow #8

Workflow file for this run

name: Build
on:
push:
paths:
- "data/**"
- ".github/workflows/build.yml"
pull_request:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
steps:
- name: Set paths
run: |
lt_dir="${{ github.workspace }}/lt"
echo "LT_HOME=${lt_dir}/languagetool" >> $GITHUB_ENV
echo "FR_DICT_HOME=${lt_dir}/french-pos-dict" >> $GITHUB_ENV
echo "LT_TMP_DIR=${lt_dir}/tmp" >> $GITHUB_ENV
- uses: actions/checkout@v3
with:
path: ${{ env.FR_DICT_HOME }}
repository: ${{ env.GITHUB_ACTION_REPOSITORY }}
fetch-depth: 0
submodules: recursive
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: Gr1N/setup-poetry@v8
- name: Check Poetry config
working-directory: ${{ env.FR_DICT_HOME }}
run: poetry check
- name: Install Python dependencies
working-directory: ${{ env.FR_DICT_HOME }}
run: poetry install --no-root
env:
POETRY_HTTP_BASIC_GITLAB_USERNAME: "lt-ai-package-registry"
POETRY_HTTP_BASIC_GITLAB_PASSWORD: ${{ secrets.POETRY_HTTP_BASIC_GITLAB_PASSWORD }}
- name: Set dictionary version
working-directory: ${{ env.FR_DICT_HOME }}
run: echo "FR_DICT_VERSION=test-$(date "+%Y-%m-%d")-$RANDOM" >> $GITHUB_ENV
- name: Set up Perl
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: "5.38"
- name: Install Perl dependencies
run: cpan install "Switch" "Text::Unaccent::PurePerl"
- name: Set up JDK 11 for x64
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
architecture: x64
- name: Checkout LT
uses: actions/checkout@v3
with:
repository: languagetool-org/languagetool
path: ${{ env.LT_HOME }}
token: ${{ secrets.LT_OS_TOKEN }}
- name: Cache LT Build
uses: actions/cache@v2
with:
path: |
${{ env.LT_HOME }}/languagetool-standalone/target
${{ env.LT_HOME }}/languagetool-dev/target
~/.m2
key: lt-build-${{ hashFiles('lt/languagetool/pom.xml', 'lt/languagetool/**/*.java') }}
id: lt-cache
- name: Build LT
if: steps.lt-cache.outputs.cache-hit != 'true'
run: mvn clean install -DskipTests
working-directory: ${{ env.LT_HOME }}
- name: Build LT Dev
if: steps.lt-cache.outputs.cache-hit != 'true'
run: mvn clean compile assembly:single
working-directory: ${{ env.LT_HOME }}/languagetool-dev
- name: Build POS tagging dictionary
working-directory: ${{ env.FR_DICT_HOME }}
run: |
poetry run python "dict_tools/scripts/build_tagger_dicts.py" \
--language fr \
--force-install \
--no-force-compile \
--spelling \
--install-version "${{ env.FR_DICT_VERSION }}"
- name: Update dictionary version in LT pom.xml
working-directory: ${{ env.FR_DICT_HOME }}
run: |
poetry run python "dict_tools/scripts/update_pom.py" \
--new-version "${{ env.FR_DICT_VERSION }}" \
--package-name "french-pos-dict"
- name: Test LT
working-directory: ${{ env.LT_HOME }}
run: |
mvn clean install -DskipTests
./build.sh fr test
- name: Archive Java src for deployment
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: src
path: ${{ env.PT_DICT_HOME }}/results/java-lt/src
deploy:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# Necessary since downloading artefacts with an 'overwrite' option is not supported
- name: Empty out src directory
run: rm -rf results/java-lt/src/*
- name: Download artefact from upstream workflow
uses: actions/download-artifact@v4
with:
name: src
path: results/java-lt/src/
- name: Set dictionary version
# TODO: remove 'test-' prefix!
run: echo "FR_DICT_VERSION=test-$(git describe --tags --abbrev=0 | sed 's/^v//g')" >> $GITHUB_ENV
- name: Set up JDK 11 for x64
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
architecture: x64
- name: Import GPG Key
run: echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
- name: Deploy to SonaType
env:
GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
working-directory: results/java-lt
run: mvn clean deploy -P release -s ${{ github.workspace }}/results/java-lt/settings.xml