diff --git a/.firebaserc b/.firebaserc index 7f3c105be..8d63e3561 100644 --- a/.firebaserc +++ b/.firebaserc @@ -10,8 +10,11 @@ ], "examples": [ "yew-rs-examples" + ], + "api": [ + "yew-rs-api" ] } } } -} +} \ No newline at end of file diff --git a/.github/workflows/build-api-docs.yml b/.github/workflows/build-api-docs.yml new file mode 100644 index 000000000..fe8d0c62d --- /dev/null +++ b/.github/workflows/build-api-docs.yml @@ -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 diff --git a/.github/workflows/publish-api-docs.yml b/.github/workflows/publish-api-docs.yml new file mode 100644 index 000000000..696a907ff --- /dev/null +++ b/.github/workflows/publish-api-docs.yml @@ -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 }}" diff --git a/firebase.json b/firebase.json index 6623ab1fe..d302e0d11 100644 --- a/firebase.json +++ b/firebase.json @@ -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 + } + } } diff --git a/tools/changelog/src/write_version_changelog.rs b/tools/changelog/src/write_version_changelog.rs index ee1959823..1eef3fc0b 100644 --- a/tools/changelog/src/write_version_changelog.rs +++ b/tools/changelog/src/write_version_changelog.rs @@ -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)?;