Skip to content

Update NLP Engine Files #4

Update NLP Engine Files

Update NLP Engine Files #4

name: Update NLP Engine Files
on:
workflow_dispatch:
jobs:
update-files:
runs-on: ubuntu-latest
steps:
- name: Checkout this repository
uses: actions/checkout@v2
- name: Get latest release info from VisualText/nlp-engine
id: get_release
uses: actions/github-script@v6
with:
script: |
const latestRelease = await github.rest.repos.getLatestRelease({
owner: 'VisualText',
repo: 'nlp-engine'
});
core.setOutput('tag_name', latestRelease.data.tag_name);
const zip = latestRelease.data.assets.find(asset => asset.name.endsWith('nlpengine.zip'));
core.setOutput('zip', zip.browser_download_url);
const icu1 = latestRelease.data.assets.find(asset => asset.name.endsWith('libicutum.a'));
core.setOutput('icu1', icu1.browser_download_url);
const icu2 = latestRelease.data.assets.find(asset => asset.name.endsWith('libicuucm.a'));
core.setOutput('icu2', icu2.browser_download_url);
const nlp = latestRelease.data.assets.find(asset => asset.name.endsWith('nlpm.exe'));
core.setOutput('nlp', nlp.browser_download_url);
- name: Download release assets to release-assets directory
run: |
mkdir release-assets
wget "${{ steps.get_release.outputs.zip }}" -P release-assets
wget "${{ steps.get_release.outputs.icu1 }}" -P release-assets
wget "${{ steps.get_release.outputs.icu2 }}" -P release-assets
wget "${{ steps.get_release.outputs.nlp }}" -P release-assets
shell: bash
- name: List runner workspace
run: find $RUNNER_WORKSPACE
shell: bash
- name: rename nlpm.exe to nlp.exe
run: mv release-assets/nlpm.exe release-assets/nlp.exe
- name: Unzip the nlpengine.zip
run: |
unzip release-assets/nlpengine.zip -d release-assets
- name: Copy assets to repository overwiriting existing files
run: |
rm -rf *.a
rm -rf nlp.exe
rm -rf data
cp -r release-assets/* .
rm -rf release-assets
rm -rf nlpengine.zip
shell: bash
- name: Commit and push changes
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Update NLP Engine files to latest release ${{ steps.get_release.outputs.tag_name }}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag this repository with the latest release version
run: |
git tag ${{ steps.get_release.outputs.tag_name }}
git push origin ${{ steps.get_release.outputs.tag_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create a release for this repository using the name "Release tag_name"
run: |
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/$GITHUB_REPOSITORY/releases -d "{\"tag_name\":\"${{ steps.get_release.outputs.tag_name }}\",\"name\":\"Release ${{ steps.get_release.outputs.tag_name }}\"}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}