diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eba30f7a..94268b1a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -70,6 +70,5 @@ jobs: needs: test uses: ./.github/workflows/docs.yml with: - short_version: next - full_version: x.y.z - default: false + version: "next" + diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 03eddc65..a4f17d09 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,23 +3,10 @@ name: Documentation on: workflow_call: inputs: - short_version: - description: The version in the format vX.Y - required: true - type: string - full_version: - description: The full version in the X.Y.Z format - required: false - type: string - default: x.y.z - label: - description: The alias for the documentation + version: + description: The version tag (v0.1.2) required: false type: string - default: - description: Is this the default documentation? - required: false - type: boolean jobs: documentation: @@ -28,11 +15,10 @@ jobs: contents: write runs-on: ubuntu-latest env: - GR_VERSION: ${{ inputs.full_version }} - GR_SHORT_VERSION: ${{ inputs.short_version }} + GR_VERSION_TAG: ${{ inputs.version }} if: ${{ github.event_name != 'pull_request' }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: '0' - uses: actions/setup-python@v4 @@ -47,11 +33,34 @@ jobs: mkdocs-material \ mkdocs-macros-plugin \ mike - - run: | - mike deploy --update-aliases --push ${{ inputs.short_version }} ${{ inputs.label }} + - name: Set version env + if: ${{ env.GR_VERSION_TAG != 'next' }} + # v1.2.3 -> + # GR_FULL_VERSION=1.2.3 + # GR_SHORT_VERSION=1.2 + # GR_PATCH_VERSION=2 + run: | + echo "GR_FULL_VERSION=$(echo $GR_VERSION_TAG | cut -d '/' -f 3 | cut -c2-)" >> $GITHUB_ENV + echo "GR_SHORT_VERSION=$(echo $GR_VERSION_TAG | cut -d '/' -f 3 | cut -d '.' -f 1,2 | cut -c2-)" >> $GITHUB_ENV + echo "GR_PATCH_VERSION=$(echo $GR_VERSION_TAG | cut -d '/' -f 3 | cut -d '.' -f 3)" >> $GITHUB_ENV + # If it is a major or minor, we mark it as latest and default. + - if: ${{ env.GR_PATCH_VERSION == '0' && env.GR_VERSION_TAG != 'next' }} + run: | + mike deploy --update-aliases --push ${{ env.GR_SHORT_VERSION }} latest + mike list + working-directory: docs + # If it is a patch, we don't set it at latest + - if: ${{ env.GR_PATCH_VERSION != '0' && env.GR_VERSION_TAG != 'next' }} + run: | + mike deploy --update-aliases --push ${{ env.GR_SHORT_VERSION }} + mike list + working-directory: docs + - if: ${{ env.GR_VERSION_TAG == 'next' }} + run: | + mike deploy --update-aliases --push next mike list working-directory: docs - run: | - mike set-default ${{ inputs.label }} - if: ${{ inputs.default == true }} + mike set-default --push latest + mike list working-directory: docs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b31b348f..032d5d46 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: DOCKER_CLI_EXPERIMENTAL: "enabled" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Fetch all tags @@ -40,33 +40,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.WORKFLOW_PAT }} documentation: - runs-on: ubuntu-latest + name: Build documentation if: ${{ github.event_name != 'pull_request' }} - needs: [ goreleaser ] - steps: - - name: Set version env - # v1.2.3 -> - # GR_FULL_VERSION=1.2.3 - # GR_SHORT_VERSION=v1.2 - # GR_PATCH_VERSION=2 - run: | - echo "GR_FULL_VERSION=$(echo $GITHUB_REF | cut -c2-)" >> $GITHUB_ENV - echo "GR_SHORT_VERSION=$(echo $GITHUB_REF | cut -d '.' -f 1,2 | cut -c2-)" >> $GITHUB_ENV - echo "GR_PATCH_VERSION=$(echo $GITHUB_REF | cut -d '.' -f 3)" >> $GITHUB_ENV - - name: Build latest documentation - # If patch is 0, it is a new release; set as new default - if: ${{ env.GR_PATCH_VERSION == '0' }} - uses: ./.github/workflows/docs.yml - with: - short_version: ${{ env.GR_SHORT_VERSION }} - full_version: ${{ env.GR_FULL_VERSION }} - label: latest - default: true - - name: Build patch documentation - # If patch is not 0, it is a patch release; don't set as default - if: ${{ env.GR_PATCH_VERSION != '0' }} - uses: ./.github/workflows/docs.yml - with: - short_version: ${{ env.GR_SHORT_VERSION }} - full_version: ${{ env.GR_FULL_VERSION }} - default: false + needs: goreleaser + uses: ./.github/workflows/docs.yml + with: + version: ${{ github.ref }} diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index f70443fa..8d8ff2dc 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -35,7 +35,7 @@ extra: version: provider: mike release: - full_version: !ENV [GR_VERSION, 'X.Y.Z'] + full_version: !ENV [GR_FULL_VERSION, 'X.Y.Z'] short_version: !ENV [GR_SHORT_VERSION, 'X.Y'] nav: