Skip to content

Commit

Permalink
Add deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
p-goulart committed Feb 5, 2024
1 parent 81e8364 commit dc87132
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
48 changes: 48 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions results/java-lt/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository />
<interactiveMode />
<offline />
<pluginGroups />
<profiles>
<profile>
<id>gpg</id>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
<servers>
<server>
<id>os.languagetool.org</id>
<username>anonymous</username>
<password>none</password>
</server>
<server>
<id>ossrh</id>
<username>${env.SONATYPE_USERNAME}</username>
<password>${env.SONATYPE_PASSWORD}</password>
</server>
</servers>
<mirrors />
<proxies />
<activeProfiles>
<activeProfile>gpg</activeProfile>
</activeProfiles>
</settings>

0 comments on commit dc87132

Please sign in to comment.