-
Notifications
You must be signed in to change notification settings - Fork 10
140 lines (112 loc) · 4.49 KB
/
maven_deployment_and_pm_update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# 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/NDStorage' }}
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-NDStorage
uses: actions/checkout@v3
with:
path: 'NDStorage'
repository: micro-manager/NDStorage
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
# this is the jar name
python build_automation/update_dependency.py NDTiffStorage NDStorage
# 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 ndstorage-update 2>/dev/null || true
git push origin --delete ndstorage-update 2>/dev/null || true
git checkout -b ndstorage-update
git commit -am "update NDStorage version and PycroManagerJava version (Created by Github action)"
- name: push
run: |
cd pycro-manager
git push --set-upstream origin ndstorage-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 ndstorage-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 ndstorage-update