Deploy SDK #50
Workflow file for this run
This file contains hidden or 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: Deploy SDK | |
| on: | |
| # Run automatically on tag push | |
| push: | |
| tags: | |
| - sdk/* | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
| # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
| concurrency: | |
| group: 'deploy-sdk' | |
| cancel-in-progress: false | |
| env: | |
| NODE_VERSION: 18.16.0 | |
| RUST_VERSION: 1.73 | |
| RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu | |
| jobs: | |
| build: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: 'recursive' | |
| # - uses: actions/setup-node@v4 | |
| # with: | |
| # node-version: ${{ env.NODE_VERSION }} | |
| # cache: yarn | |
| # - name: Install rust | |
| # run: rustup default ${{ env.RUST_VERSION }} | |
| # - uses: Swatinem/rust-cache@v2 | |
| # with: | |
| # workspaces: | | |
| # packages/rust-bindings | |
| # deps/concordium-base/rust-src | |
| # deps/concordium-base/smart-contracts/contracts-common | |
| # - name: Cache dependencies | |
| # id: yarn-cache | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: | | |
| # ./node_modules | |
| # ./docs/node_modules | |
| # ./packages/*/node_modules | |
| # ./examples/**/node_modules | |
| # key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
| # restore-keys: | | |
| # ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} | |
| # - name: Cache GRPC | |
| # id: cache-grpc | |
| # uses: actions/cache@v4 | |
| # with: | |
| # path: | | |
| # ./packages/sdk/src/grpc-api | |
| # key: ${{ runner.os }}-grpc-${{ hashFiles('deps/concordium-base/concordium-grpc-api') }} | |
| # restore-keys: ${{ runner.os }}-grpc | |
| # - name: Get dependencies | |
| # if: steps.yarn-cache.outputs.cache-hit != 'true' | |
| # run: yarn install --immutable | |
| # - name: Build release | |
| # run: yarn build:all | |
| # - name: Generate typedoc documentation | |
| # run: yarn build:docs | |
| # - name: Store build-release | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: build-release | |
| # path: | | |
| # packages/sdk/lib | |
| # packages/sdk/src | |
| # packages/sdk/package.json | |
| # packages/sdk/README.md | |
| # - name: Store typedoc | |
| # uses: actions/upload-artifact@v4 | |
| # with: | |
| # name: typedoc-build | |
| # path: typedoc | |
| upload-release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| # environment: deploy | |
| outputs: | |
| npm_tag: ${{ steps.determine_npm_tag.outputs.npm_tag }} | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v5 | |
| with: | |
| submodules: recursive | |
| # - name: Extract tag name | |
| # id: get_tag | |
| # # ${GITHUB_REF#refs/tags/sdk/} | |
| # # Hardcoded for testing | |
| # run: echo "tag=10.0.1" >> $GITHUB_OUTPUT | |
| # - name: Test that tag version matches package.json version | |
| # run: test "${{ steps.get_tag.outputs.tag }}" = "$(jq -r ".version" packages/sdk/package.json)" || exit 1 | |
| # - name: Determine npm tag | |
| # id: determine_npm_tag | |
| # run: | | |
| # version=$(jq -r ".version" packages/sdk/package.json) | |
| # if [[ "$version" == *-* ]]; then | |
| # npm_tag=$(echo "$version" | cut -d'-' -f2 | cut -d'.' -f1) | |
| # else | |
| # npm_tag="latest" | |
| # fi | |
| # echo "npm_tag=$npm_tag" >> $GITHUB_OUTPUT | |
| # - name: Get build-output | |
| # uses: actions/download-artifact@v5 | |
| # with: | |
| # name: build-release | |
| # path: packages/sdk | |
| # - uses: actions/setup-node@v4 | |
| # with: | |
| # node-version: ${{ env.NODE_VERSION }} | |
| # cache: yarn | |
| # registry-url: 'https://registry.npmjs.org' | |
| # - name: Publish to NPM | |
| # run: | | |
| # yarn config set npmAuthToken $NPM_AUTH_TOKEN | |
| # yarn workspace @concordium/web-sdk npm publish --tag ${{ steps.determine_npm_tag.outputs.npm_tag }} | |
| # env: | |
| # NPM_AUTH_TOKEN: '${{secrets.NPM_PUBLISH_TOKEN}}' | |
| # - name: Create a GitHub release | |
| # uses: ncipollo/release-action@v1 | |
| # with: | |
| # tag: sdk/${{ steps.get_tag.outputs.tag }} | |
| # name: SDK Release v${{ steps.get_tag.outputs.tag }} | |
| # draft: true | |
| deploy-typedoc: | |
| needs: | |
| - upload-release | |
| environment: | |
| name: github-pages | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| # Get already published documentation | |
| # - name: Fetch old gh-pages content (old doc versions) | |
| # run: | | |
| # mkdir -p docs | |
| # if git ls-remote --exit-code origin gh-pages; then | |
| # echo "'gh-pages' branch does exist" | |
| # # Clone old `gh-pages` branch into temp folder | |
| # git clone --branch gh-pages --depth 1 https://github.com/${{ github.repository }} old-gh-pages | |
| # # Copy existing docs into 'docs/' folder | |
| # cp -r old-gh-pages/* docs/ || true | |
| # else | |
| # echo "'gh-pages' branch does not exist yet" | |
| # fi | |
| # - name: Get typedoc | |
| # uses: actions/download-artifact@v5 | |
| # with: | |
| # path: typedoc | |
| # name: typedoc-build | |
| # TODO: remove again just for testing | |
| - name: Add some dummy docs | |
| run: | | |
| mkdir -p typedoc && echo 'docs dummy' > typedoc/index.html | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| # Put new docs into a versioned subfolder | |
| # TODO: add this again => VERSION=${{ needs.upload-release.outputs.tag }} | |
| - name: Generate versioned subfolder | |
| run: | | |
| VERSION=10.0.2 | |
| mkdir -p gh-pages/$VERSION | |
| cp -r typedoc/* gh-pages/$VERSION | |
| # Update the "latest" subfolder content with the newest doc version. | |
| - name: Update `latest` subfolder content | |
| # TODO: add this again => if: needs.upload-release.outputs.npm_tag == 'latest' | |
| run: | | |
| mkdir -p gh-pages/latest | |
| rm -rf gh-pages/latest/* | |
| cp -r typedoc/* gh-pages/latest | |
| - name: Deploy | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./gh-pages | |
| keep_files: true | |
| # Generate list of available documentation versions. | |
| # This needs to be done after the `gh-pages` branch has been updated by above `Deploy` run. | |
| - name: Generate docs index | |
| run: | | |
| echo "<!DOCTYPE html>" > gh-pages/index.html | |
| echo "<html><head><title>Documentation Versions</title></head><body>" >> gh-pages/index.html | |
| echo "<h1>Available Documentation Versions</h1><ul>" >> gh-pages/index.html | |
| # Loop over directories in gh-pages branch | |
| for d in $(git ls-tree -d --name-only origin/gh-pages); do | |
| echo "<li><a href=\"./$d/\">$d</a></li>" >> gh-pages/index.html | |
| done | |
| echo "</ul>" >> gh-pages/index.html | |
| echo "</body></html>" >> gh-pages/index.html | |
| - name: Deploy again (this time with updated `list of available documentation versions`) | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./gh-pages | |
| keep_files: true |