diff --git a/.github/workflows/publish-doc.yml b/.github/workflows/publish-doc.yml new file mode 100644 index 000000000..a093ca148 --- /dev/null +++ b/.github/workflows/publish-doc.yml @@ -0,0 +1,62 @@ +name: ci + +on: + push: + tags: + - v* + +permissions: + contents: write + pull-requests: write + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v4 + with: + python-version: 3.x + + - uses: actions/cache@v2 + with: + key: ${{ github.ref }} + path: .cache + + - name: Install Python dependencies + run: pip install -r ./docs/pip-requirements.txt + + - name: Configure git user + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + + - name: Deploy docs to gh-pages + run: | + VERSION=${{ github.ref }} + VERSION=${VERSION#refs/tags/} + BASE_VERSION=${VERSION#v} + + echo "Deploying documentation for version: $BASE_VERSION" + + cd docs + mike deploy --update-aliases $BASE_VERSION latest + + cd .. + git fetch origin gh-pages + git checkout gh-pages + git pull origin gh-pages + + mkdir -p "./$BASE_VERSION" && cp -r docs/build/* "./$BASE_VERSION" + + git add . + git commit -m "Update documentation for version $BASE_VERSION" + git push origin gh-pages + + - name: Notify about PR + run: echo "Pull request created ${{ steps.create_pr.outputs.pr_url }}" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index be9071f06..c2ced6409 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -13,4 +13,43 @@ ## Caliper benchmarks 1. Create a release in caliper-benchmarks corresponding to the new release, eg 0.7.0 +## Documentation Deployment +This repository uses GitHub Actions to automate the deployment of documentation to GitHub Pages whenever a new version is tagged. Follow the steps below to change the version and deploy updated documentation. + +### Steps to Change Version and Deploy Documentation + +1. Create a Git Tag for the New Version + +To deploy a new version of the documentation, start by creating a Git tag. For example: + +```bash +git tag v1.2 +``` + +2. Push the Tag to GitHub +Once the tag is created, push it to GitHub: + +```bash +git push origin v1.2.3 +``` + +Pushing the tag will automatically trigger the GitHub Actions CI pipeline defined in the .github/workflows/publish-doc.yml file. + +3. CI Pipeline Actions +When the tag is pushed, the CI pipeline will execute the following steps: + +Checkout Code: The latest version of the repository is pulled. +Setup Python: Python 3.x is set up and the required dependencies are installed from the docs/pip-requirements.txt. +Deploy Documentation: The mike deploy command is used to deploy the documentation to the gh-pages branch under the new version folder (/v1.2.3/). +Create Pull Request: A new branch is created to update the docs folder, and a pull request is opened to merge the changes into the main branch. + +4. Merge the Pull Request +After the pull request is created, review the changes and merge it into the main branch. This ensures the documentation for the new version is available on the main repository. + +5. Access the Documentation +Once the pull request is merged, the updated documentation can be accessed through GitHub Pages. The URL format will be: + +```bash +https://hyperledger-caliper.github.io/caliper/ +``` \ No newline at end of file