forked from robolectric/robolectric.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a workflow to publish the Javadoc when a specific issue is cre…
…ated
- Loading branch information
Showing
2 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
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-22.04 | ||
|
||
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.minorVersion }} | ||
run: | | ||
cd robolectric.github.io | ||
targetFolder=docs/javadoc/${{ steps.robolectric_version.outputs.minorVersion }} | ||
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.minorVersion }} | ||
run: | | ||
cd robolectric.github.io | ||
sed -i 's/^ current: ".*"$/ current: "${{ steps.robolectric_version.outputs.minorVersion }}"/' mkdocs.yml | ||
sed -i 's/^ current_patched: ".*"$/ current_patched: "${{ steps.robolectric_version.outputs.patchVersion }}"/' mkdocs.yml | ||
if [ "${{ steps.robolectric_version.outputs.minorVersion }}" == "${{ steps.robolectric_version.outputs.patchVersion }}" ]; then | ||
sed -i 's/^\( - "Javadoc":\)$/\1\n - "${{ steps.robolectric_version.outputs.minorVersion }}": \/javadoc\/${{ steps.robolectric_version.outputs.minorVersion }}\//' mkdocs.yml | ||
fi | ||
- name: Update latest javadoc symbolic link | ||
if: ${{ steps.robolectric_version.outputs.minorVersion }} | ||
run: | | ||
cd robolectric.github.io | ||
ln -sfn ${{ steps.robolectric_version.outputs.minorVersion }} docs/javadoc/latest | ||
- name: Create Pull Request | ||
if: ${{ steps.robolectric_version.outputs.patchVersion }} | ||
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.id }}" | ||
git push --set-upstream origin publish-javadoc-robolectric-${{ steps.robolectric_version.outputs.patchVersion }} | ||
gh pr create --fill |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters