forked from robolectric/robolectric.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (85 loc) · 4.04 KB
/
publish-javadoc.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
name: Publish javadoc
on:
issues:
types: [ opened ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
publish-javadoc:
name: Publish javadoc
runs-on: ubuntu-latest
steps:
- name: Extract Robolectric version
id: robolectric_version
run: |
authorAssociation="${{ github.event.issue.author_association }}"
if [[ "$authorAssociation" == "COLLABORATOR" || "$authorAssociation" == "MEMBER" || "$authorAssociation" == "OWNER" ]]; then
issueTitle="${{ github.event.issue.title }}"
if [[ "$issueTitle" =~ ^Publish\ javadoc\ for\ (([0-9]+\.[0-9]+)(\.[0-9]+)?)$ ]]; then
robolectricMinorVersion="${BASH_REMATCH[2]}"
robolectricPatchVersion="${BASH_REMATCH[1]}"
echo "minorVersion=$robolectricMinorVersion" > $GITHUB_OUTPUT
echo "patchVersion=$robolectricPatchVersion" >> $GITHUB_OUTPUT
fi
fi
- name: Checkout Robolectric
uses: actions/checkout@v4
if: ${{ steps.robolectric_version.outputs.patchVersion }}
with:
repository: robolectric/robolectric
path: robolectric
ref: robolectric-${{ steps.robolectric_version.outputs.patchVersion }}
- name: Checkout robolectric.github.io
uses: actions/checkout@v4
if: ${{ steps.robolectric_version.outputs.minorVersion }}
with:
path: robolectric.github.io
- name: Set up JDK 17
uses: actions/setup-java@v4
if: ${{ steps.robolectric_version.outputs.minorVersion }}
with:
distribution: 'adopt'
java-version: 17
- name: Assemble and aggregate javadoc
if: ${{ steps.robolectric_version.outputs.minorVersion }}
run: |
cd robolectric
./gradlew clean aggregateDocs
- name: Move the new javadoc
if: ${{ steps.robolectric_version.outputs.patchVersion }}
run: |
cd robolectric.github.io
targetFolder="docs/javadoc/${{ steps.robolectric_version.outputs.patchVersion }}"
if [ -e $targetFolder ]; then
rm -r $targetFolder
fi
mv ../robolectric/build/docs/javadoc $targetFolder
- name: Update Robolectric version in mkdocs.yml
if: ${{ steps.robolectric_version.outputs.patchVersion }}
run: |
cd robolectric.github.io
sed -i 's/^ current: ".*"$/ current: "${{ steps.robolectric_version.outputs.patchVersion }}"/' mkdocs.yml
sed -i 's/^\( - "Javadoc":\)$/\1\n - "${{ steps.robolectric_version.outputs.patchVersion }}": \/javadoc\/${{ steps.robolectric_version.outputs.patchVersion }}\//' mkdocs.yml
- name: Update latest javadoc symbolic link
if: ${{ steps.robolectric_version.outputs.patchVersion }}
run: |
cd robolectric.github.io
ln -sfn ${{ steps.robolectric_version.outputs.patchVersion }} docs/javadoc/latest
- name: Create Pull Request
if: ${{ steps.robolectric_version.outputs.patchVersion }}
env:
GH_TOKEN: ${{ github.token }}
run: |
cd robolectric.github.io
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b publish-javadoc-robolectric-${{ steps.robolectric_version.outputs.patchVersion }}
git add -A
git commit -m "Publish javadoc for Robolectric ${{ steps.robolectric_version.outputs.patchVersion }}" \
-m "- Add javadoc for Robolectric ${{ steps.robolectric_version.outputs.patchVersion }}." \
-m "- Update mkdocs.yml to add a navigation entry to the new javadoc." \
-m "- Update mkdocs.yml to use version ${{ steps.robolectric_version.outputs.patchVersion }}." \
-m "Fixes #${{ github.event.issue.number }}"
git push --set-upstream origin publish-javadoc-robolectric-${{ steps.robolectric_version.outputs.patchVersion }}
gh pr create --fill