Setup hosting for API docs (#2371)

* setup hosting for API docs

* maybe this is the name of the component??

* dependencies make the final bundle too big

* please clippy
This commit is contained in:
Muhammad Hamza 2022-01-15 17:21:24 +05:00 committed by GitHub
parent f05ba4152c
commit 44e3880c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 145 additions and 3 deletions

View File

@ -10,8 +10,11 @@
],
"examples": [
"yew-rs-examples"
],
"api": [
"yew-rs-api"
]
}
}
}
}
}

55
.github/workflows/build-api-docs.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name: Build API Docs (Rustdoc)
on:
pull_request:
branches: [master]
paths:
- "packages/**"
- "firebase.json"
- ".github/workflows/*-docs.yml"
push:
branches: [master]
paths:
- "packages/**"
- "firebase.json"
- ".github/workflows/*-docs.yml"
jobs:
build:
runs-on: ubuntu-latest
env:
PR_INFO_FILE: ".PR_INFO"
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: rust-docs
- name: Run cargo doc
uses: actions-rs/cargo@v1
with:
command: doc
args: -p yew -p yew-macro -p yew-router -p yew-router-macro -p yew-agent --no-deps
- name: Upload build artifact
uses: actions/upload-artifact@v2
with:
name: api-docs
path: target/doc/
retention-days: 1
- if: github.event_name == 'pull_request'
name: Build pr info
run: |
echo "${{ github.event.number }}" > $PR_INFO_FILE
- if: github.event_name == 'pull_request'
name: Upload pr info
uses: actions/upload-artifact@v2
with:
name: pr-info
path: "${{ env.PR_INFO_FILE }}"
retention-days: 1

70
.github/workflows/publish-api-docs.yml vendored Normal file
View File

@ -0,0 +1,70 @@
name: Publish API Docs
on:
workflow_run:
workflows: ["Build API Docs (Rustdoc)"]
types:
- completed
jobs:
publish:
runs-on: ubuntu-latest
env:
PR_INFO_FILE: ".PR_INFO"
steps:
- if: github.event.workflow_run.conclusion != 'success'
name: Abort if build failed
run: |
echo "build failed"
exit 1
# need to checkout to get "firebase.json", ".firebaserc"
- uses: actions/checkout@v2
- name: Download build artifact
uses: dawidd6/action-download-artifact@v2
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
workflow: build-api-docs.yml
run_id: ${{ github.event.workflow_run.id }}
name: api-docs
path: target/doc/
- if: github.event.workflow_run.event == 'pull_request'
name: Download pr info
uses: dawidd6/action-download-artifact@v2
with:
github_token: "${{ secrets.GITHUB_TOKEN }}"
workflow: build-api-docs.yml
run_id: ${{ github.event.workflow_run.id }}
name: pr-info
- if: github.event.workflow_run.event == 'pull_request'
name: Apply pull request environment
run: |
pr_number=$(cat "$PR_INFO_FILE")
if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then
echo "pr number invalid"
exit 1
fi
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
echo "PR_BRANCH=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_ENV
echo "COMMIT_SHA=${{ github.event.workflow_run.head_sha }}" >> $GITHUB_ENV
- if: github.event.workflow_run.event == 'push'
name: Apply push environment
run: |
echo "CHANNEL_ID=live" >> $GITHUB_ENV
- name: Deploy to Firebase
uses: siku2/action-hosting-deploy@v1
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseToken: "${{ secrets.FIREBASE_TOKEN }}"
targets: api
channelId: "${{ env.CHANNEL_ID }}"
# link to the next version because that's what we care about
commentURLPath: "/yew"
# PR information
prNumber: "${{ env.PR_NUMBER }}"
prBranchName: "${{ env.PR_BRANCH }}"
commitSHA: "${{ env.COMMIT_SHA }}"

View File

@ -6,6 +6,12 @@
"cleanUrls": true,
"redirects": []
},
{
"target": "api",
"public": "target/doc/",
"cleanUrls": true,
"redirects": []
},
{
"target": "examples",
"public": "dist",
@ -27,5 +33,13 @@
}
]
}
]
],
"emulators": {
"hosting": {
"port": 5000
},
"ui": {
"enabled": true
}
}
}

View File

@ -19,7 +19,7 @@ pub fn write_changelog_file(
version_only_changelog,
"## ✨ {package} **{next_version}** *({release_date})* Changelog",
next_version = next_version,
package = package.to_string(),
package = package,
release_date = chrono::Utc::now().format("%Y-%m-%d")
)?;
writeln!(version_only_changelog)?;