From dc8713251fd1f1e0b6af3992b66c2a93e05eb4f9 Mon Sep 17 00:00:00 2001 From: p-goulart Date: Mon, 5 Feb 2024 11:48:11 +0100 Subject: [PATCH] Add deploy workflow --- .github/workflows/build.yml | 11 ++++++++- .github/workflows/deploy.yml | 48 ++++++++++++++++++++++++++++++++++++ results/java-lt/settings.xml | 33 +++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 results/java-lt/settings.xml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0cd5944..f8c4e9b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,7 +57,7 @@ jobs: - name: Set dictionary version working-directory: ${{ env.PT_DICT_HOME }} - run: echo "PT_DICT_VERSION=test-$(git describe --tags --abbrev=0 | sed 's/^v//g')" >> $GITHUB_ENV + run: echo "PT_DICT_VERSION=test-$(date "+%Y-%m-%d)-$RANDOM" >> $GITHUB_ENV - name: Set up Perl uses: shogo82148/actions-setup-perl@v1 @@ -136,3 +136,12 @@ jobs: run: | mvn clean install -DskipTests ./build.sh pt test + + - name: Archive Java src for deployment + # TODO: uncomment after this is tested to limit archiving to PRs to main + # Only do it after a successful build and push to main + if: github.event_name == 'push' && github.ref == 'refs/heads/main' + uses: actions/upload-artifact@v2 + with: + name: src + path: ${{ env.PT_DICT_HOME }}/results/java-lt/src diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..e8e1a4f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,48 @@ +name: Deploy + +on: + workflow_run: + workflows: ["Build"] + types: + - completed + +jobs: + deploy: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.head_branch == 'main' + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: src + + - name: Set dictionary version + # TODO: remove 'test-' prefix! + run: echo "PT_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 + + # This step makes sure that we're using the settings.xml file with env vars prepared for GPG and SonaType + - name: Copy settings.xml to m2 + run: cp results/java-lt/settings.xml $HOME/.m2/settings.xml + + # Add your deployment steps here + - name: Deploy + env: + GPG_KEYNAME: ${{ secrets.GPG_KEYNAME }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: | + mvn clean deploy -P release diff --git a/results/java-lt/settings.xml b/results/java-lt/settings.xml new file mode 100644 index 0000000..261797c --- /dev/null +++ b/results/java-lt/settings.xml @@ -0,0 +1,33 @@ + + + + + + + + gpg + + gpg + ${env.GPG_PASSPHRASE} + + + + + + os.languagetool.org + anonymous + none + + + ossrh + ${env.SONATYPE_USERNAME} + ${env.SONATYPE_PASSWORD} + + + + + + gpg + +