Publish javadoc for 4.14-beta-1 #9
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
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 |