Clarify string format of replaces_state
#4919
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: "Spec" | |
| env: | |
| HUGO_VERSION: 0.155.3 | |
| PYTHON_VERSION: 3.13 | |
| NODE_VERSION: 24 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - v* | |
| pull_request: | |
| workflow_dispatch: | |
| schedule: | |
| # Run this workflow every day at 2am. This helps keep the page of | |
| # current spec proposals up-to-date. | |
| - cron: '0 2 * * *' | |
| jobs: | |
| validate-openapi: | |
| name: "π Validate OpenAPI specifications" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "β Setup Node" | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: "π Run validator" | |
| run: | | |
| npx @redocly/cli@2.31.5 lint data/api/*/*.yaml | |
| check-event-examples: | |
| name: "π Check Event schema examples" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "β Setup Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' | |
| cache-dependency-path: scripts/requirements.txt | |
| - name: "β Install dependencies" | |
| run: | | |
| pip install -r scripts/requirements.txt | |
| - name: "π Run validator" | |
| run: | | |
| python scripts/check-event-schema-examples.py | |
| check-openapi-examples: | |
| name: "π Check OpenAPI definitions examples" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "β Setup Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' | |
| cache-dependency-path: scripts/requirements.txt | |
| - name: "β Install dependencies" | |
| run: | | |
| pip install -r scripts/requirements.txt | |
| - name: "π Run validator" | |
| run: | | |
| python scripts/check-openapi-sources.py | |
| check-schemas-examples: | |
| name: "π Check JSON Schemas inline examples" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "β Setup Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' | |
| cache-dependency-path: scripts/requirements.txt | |
| - name: "β Install dependencies" | |
| run: | | |
| pip install -r scripts/requirements.txt | |
| - name: "π Run validator" | |
| run: | | |
| python scripts/check-json-schemas.py | |
| calculate-baseurl: | |
| name: "βοΈ Calculate baseURL for later jobs" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| baseURL: "${{ steps.set-baseurl.outputs.baseURL }}" | |
| steps: | |
| # For PRs, set the baseURL to `/`. | |
| # For releases, set the baseURL to `/$tag` (eg: `/v1.2`). | |
| # Otherwise, set it to `/unstable`. | |
| - name: "βοΈ Calculate baseURL" | |
| id: set-baseurl | |
| # Double brackets on the elif to avoid auto-escaping refs/tags/* because we need | |
| # the asterisk matching behaviour, not the literal string. | |
| run: | | |
| if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then | |
| echo "baseURL=/" >> "$GITHUB_OUTPUT" | |
| elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| echo "baseURL=/${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "baseURL=/unstable" >> "$GITHUB_OUTPUT" | |
| fi | |
| build-openapi: | |
| name: "π Build OpenAPI definitions" | |
| runs-on: ubuntu-latest | |
| needs: [calculate-baseurl] | |
| steps: | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "β Setup Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| cache: 'pip' | |
| cache-dependency-path: scripts/requirements.txt | |
| - name: "β Install dependencies" | |
| run: | | |
| pip install -r scripts/requirements.txt | |
| - name: "π¦ Asset creation" | |
| run: | | |
| if [[ "${GITHUB_REF}" == refs/tags/* ]]; then | |
| export RELEASE="${GITHUB_REF/refs\/tags\//}" | |
| else | |
| export RELEASE="unstable" | |
| fi | |
| # The output path matches the final deployment path at spec.matrix.org | |
| scripts/dump-openapi.py \ | |
| --base-url "https://spec.matrix.org${{ needs.calculate-baseurl.outputs.baseURL }}" \ | |
| --api application-service \ | |
| -r "$RELEASE" \ | |
| -o spec/application-service-api/api.json | |
| scripts/dump-openapi.py \ | |
| --base-url "https://spec.matrix.org${{ needs.calculate-baseurl.outputs.baseURL }}" \ | |
| --api client-server \ | |
| -r "$RELEASE" \ | |
| -o spec/client-server-api/api.json | |
| scripts/dump-openapi.py \ | |
| --base-url "https://spec.matrix.org${{ needs.calculate-baseurl.outputs.baseURL }}" \ | |
| --api push-gateway \ | |
| -r "$RELEASE" \ | |
| -o spec/push-gateway-api/api.json | |
| scripts/dump-openapi.py \ | |
| --base-url "https://spec.matrix.org${{ needs.calculate-baseurl.outputs.baseURL }}" \ | |
| --api server-server \ | |
| -r "$RELEASE" \ | |
| -o spec/server-server-api/api.json | |
| scripts/dump-openapi.py \ | |
| --base-url "https://spec.matrix.org${{ needs.calculate-baseurl.outputs.baseURL }}" \ | |
| --api identity \ | |
| -r "$RELEASE" \ | |
| -o spec/identity-service-api/api.json | |
| tar -czf openapi.tar.gz spec | |
| - name: "π€ Artifact upload" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: openapi-artifact | |
| path: openapi.tar.gz | |
| generate-changelog: | |
| name: "π’ Run towncrier for changelog" | |
| # skip for builds of git tags | |
| if: "!startsWith(github.ref, 'refs/tags/')" | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "β Setup Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: "β Install towncrier" | |
| run: "pip install 'towncrier'" | |
| - name: "Generate changelog" | |
| run: ./scripts/generate-changelog.sh vUNSTABLE | |
| - name: "π€ Artifact upload" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: changelog-artifact | |
| path: content/changelog/unstable.md | |
| build-spec: | |
| name: "π Build the spec" | |
| runs-on: ubuntu-latest | |
| needs: [calculate-baseurl, build-openapi, generate-changelog] | |
| # run even if generate-changelog was skipped | |
| if: ${{ always() }} | |
| env: | |
| baseURL: "${{ needs.calculate-baseurl.outputs.baseURL }}" | |
| steps: | |
| - name: "β Setup Node" | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: "β Setup Hugo" | |
| uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 | |
| with: | |
| hugo-version: ${{ env.HUGO_VERSION }} | |
| extended: true | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "βοΈ npm" | |
| run: | | |
| npm i | |
| npm run get-proposals | |
| - name: "π₯ Download generated changelog" | |
| if: "needs.generate-changelog.result == 'success'" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: changelog-artifact | |
| path: content/changelog | |
| - name: "βοΈ hugo" | |
| run: hugo --baseURL "${baseURL}" -d "spec${baseURL}" | |
| # We manually unpack the spec OpenAPI definition JSON to the website tree | |
| # to make it available to the world in a canonical place: | |
| # https://spec.matrix.org/latest/client-server-api/api.json | |
| # Works for /unstable/ and /v1.1/ as well. | |
| - name: "π₯ Spec definition download" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: openapi-artifact | |
| - name: "π Unpack the OpenAPI definitions in the right location" | |
| run: | | |
| tar -C "spec${baseURL}" --strip-components=1 -xzf openapi.tar.gz | |
| - name: "π pagefind indexing" | |
| run: | | |
| npm run pagefind -- --site "spec${baseURL}" | |
| - name: "π¦ Tarball creation" | |
| run: | | |
| cd spec | |
| tar -czf ../spec.tar.gz * | |
| - name: "π€ Artifact upload" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: spec-artifact | |
| path: spec.tar.gz | |
| htmlcheck: | |
| name: "π Validate generated HTML" | |
| runs-on: ubuntu-latest | |
| needs: [calculate-baseurl, build-spec] | |
| # Run even if `generate-changelog` was skipped. | |
| # | |
| # `build-spec` has a dependency on `generate-changelog` to ensure order of execution | |
| # and to access `needs.generate-changelog.result`. However, `generate-changelog` is | |
| # skipped on tag builds; even a transient dependency on `generate-changelog` is then | |
| # enough for this step to also be skipped by default on tag builds. Hence the need for | |
| # this explicit `if`. | |
| if: ${{ !failure() && !cancelled() }} | |
| steps: | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "π₯ Fetch built spec" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: spec-artifact | |
| - name: "π Unpack the spec" | |
| run: | | |
| mkdir spec | |
| tar -C spec -xvzf spec.tar.gz | |
| - name: "Run htmltest" | |
| uses: wjdp/htmltest-action@master | |
| with: | |
| config: .htmltest.yml | |
| build-historical-spec: | |
| name: "π Build the historical backup spec" | |
| runs-on: ubuntu-latest | |
| needs: [calculate-baseurl, build-openapi] | |
| if: ${{ startsWith(github.ref, 'refs/tags/') }} | |
| env: | |
| baseURL: "${{ needs.calculate-baseurl.outputs.baseURL }}" | |
| steps: | |
| - name: "β Setup Node" | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: "β Setup Hugo" | |
| uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0 | |
| with: | |
| hugo-version: ${{ env.HUGO_VERSION }} | |
| extended: true | |
| - name: "π₯ Source checkout" | |
| uses: actions/checkout@v4 | |
| - name: "βοΈ npm" | |
| run: | | |
| npm i | |
| npm run get-proposals | |
| - name: "βοΈ hugo" | |
| env: | |
| HUGO_PARAMS_VERSION_STATUS: "historical" | |
| run: | | |
| hugo --baseURL "${baseURL}" -d "spec${baseURL}" | |
| - name: "π₯ Spec definition download" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: openapi-artifact | |
| - name: "π Unpack the OpenAPI definitions in the right location" | |
| run: | | |
| tar -C "spec${baseURL}" --strip-components=1 -xzf openapi.tar.gz | |
| - name: "π¦ Tarball creation" | |
| run: | | |
| cd spec | |
| tar -czf ../spec-historical.tar.gz * | |
| - name: "π€ Artifact upload" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: spec-historical-artifact | |
| path: spec-historical.tar.gz | |
| # If we're building a tag, create a release and publish the artifacts | |
| create_release: | |
| name: "Create release" | |
| if: ${{ !failure() && !cancelled() && startsWith(github.ref, 'refs/tags/') }} | |
| needs: | |
| - build-spec | |
| - build-historical-spec | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: "π₯ Check out changelogs" | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 | |
| with: | |
| sparse-checkout: | | |
| content/changelog | |
| - name: "π₯ Download built spec" | |
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 | |
| with: | |
| name: spec-artifact | |
| - name: "π₯ Download historical spec artifact" | |
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0 | |
| with: | |
| name: spec-historical-artifact | |
| - name: "β¨ Create draft release" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Remove front-matter from changelog | |
| sed '1,/^---$/d' "content/changelog/${{ github.ref_name }}.md" > changelog.md | |
| # Create a draft release, using the changelog as release notes, and attaching the spec artifacts. | |
| gh release create -d -t "${{ github.ref_name }}" \ | |
| -F "changelog.md" \ | |
| "${{ github.ref_name }}" \ | |
| spec.tar.gz \ | |
| spec-historical.tar.gz |