Skip to content

Merge pull request #134 from henrypinkard/main #40

Merge pull request #134 from henrypinkard/main

Merge pull request #134 from henrypinkard/main #40

# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Maven_depolyment and pycromanager update
on:
push:
branches:
- main
paths:
- 'java/pom.xml'
# only let one instance run at a time
concurrency: version_update
jobs:
maven-deploy:
name: Maven deploy to Sonatype OSS
runs-on: ubuntu-latest
if: ${{ github.repository == 'micro-manager/NDTiffStorage' }}
steps:
- uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: 8
distribution: 'zulu'
- name: Set up Apache Maven Central
uses: actions/setup-java@v3
with: # running setup-java again overwrites the settings.xml
java-version: 8
distribution: 'zulu'
server-id: ossrh
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Publish to Apache Maven Central
run: cd java && mvn deploy -Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }}
env:
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
update-pycromanger:
needs: maven-deploy
runs-on: ubuntu-latest
steps:
# Get token for using gh CLI
# https://michaelheap.com/ultimate-guide-github-actions-authentication/
- name: Get Token
id: get_workflow_token
uses: getsentry/action-github-app-token@v2
with:
app_id: ${{ secrets.MM_PR_BOT_APP_ID }}
private_key: ${{ secrets.MM_PR_BOT_PRIVATE_KEY }}
- name: Checkout-PM
uses: actions/checkout@v3
with:
path: pycro-manager
repository: micro-manager/pycro-manager
token: ${{ steps.get_workflow_token.outputs.token }}
- name: Checkout-NDTiff
uses: actions/checkout@v3
with:
path: 'NDTiffStorage'
repository: micro-manager/NDTiffStorage
token: ${{ steps.get_workflow_token.outputs.token }}
- name: update-version
run: |
cd pycro-manager
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "NDStorage-Bot"
git config pull.rebase false
python build_automation/update_dependency.py NDTiffStorage
# Now bump version of PycroManagerJava.jar to reflect its updated dependency
pip install semantic_version
python build_automation/update_PycroManagerJava.py
- name: commit
run: |
cd pycro-manager
# delete any errant existing version of the update branch
git branch -D ndtiff-update 2>/dev/null || true
git push origin --delete ndtiff-update 2>/dev/null || true
git checkout -b ndtiff-update
git commit -am "update NDTiffStorage version and PycroManagerJava version (Created by Github action)"
- name: push
run: |
cd pycro-manager
git push --set-upstream origin ndtiff-update
- name: create pull request
# make a PR from *-update branch of PM to main branch
env:
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
run: |
cd pycro-manager
PR_URL=$(gh pr create -H ndtiff-update -B main --title 'Java dependency auto-update' --body 'Created by Github action')
echo "Created pull request $PR_URL"
# supposedly you can use --delete-branch here, but as of 2-1-23 it doesn't work
gh pr merge $PR_URL --auto --merge
# Block until PR merged or closed
while true; do
if gh pr view $PR_URL --json state | grep -q "MERGED"; then
echo "success merge"
break
elif gh pr view $PR_URL --json state | grep -q "CLOSED"; then
echo "pull request closed"
break
else
echo "waiting on pull request status"
sleep 10
fi
done
# Now it is safe to assume its in the nightly builds
# delete the branch created for sending in the update
git push origin --delete ndtiff-update