From 2609b3576ec912b955a5b4a7398ce48f8e39e879 Mon Sep 17 00:00:00 2001 From: Paul Schultz Date: Tue, 20 Sep 2022 09:05:05 -0500 Subject: [PATCH] Update landing page release/publish scripts (#921) Signed-off-by: Paul Schultz --- .github/workflows/ci.yaml | 173 ++++++++++++++------------ .github/workflows/release-schema.yaml | 78 +++++------- 2 files changed, 122 insertions(+), 129 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 69866bd78..0f22c53e3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,73 +3,73 @@ name: CI # Triggers the workflow on push or pull request events but only for the main branch on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: build-and-validate: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - - name: Setup Go environment - uses: actions/setup-go@v2.1.3 - with: - # The Go version to download (if necessary) and use. Supports semver spec and ranges. - go-version: 1.18 - - - name: Generate Go sources, CRDs and schemas - run: | - ./docker-run.sh ./build.sh - if [[ ! -z $(git status -s) ]] - then - echo 'Command `./docker-run.sh ./build.sh` did introduce changes, which should not be the case if it had been run as part of the PR. Please run it locally and check in the results as part of your PR.' - git --no-pager diff - exit 1 - fi - - - name: Validate samples against schemas - run: ./docker-run.sh ./validate-samples.sh - - - name: Run GO tests - run: go test -coverprofile cover.out -v ./... - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2.1.0 - - - name: Check typescript model generation - run: ./build/typescript-model/generate.sh - - - name: Check GO mod state - run: | - go mod tidy - go mod vendor - git diff --exit-code || { echo 'Go mod is not clean. Execute "go mod tidy && go mod vendor" locally and commit changes to fix an issue'; exit 1; } - - - name: Check GO format - run: | - go fmt -x ./... - git diff --exit-code || { echo 'Go sources need to be formated. Execute "go fmt -x ./..." locally and commit changes to fix an issue'; exit 1; } - - - name: Check Generator GO mod state - working-directory: generator - run: | - go mod tidy - go mod vendor - git diff --exit-code || { echo 'Go mod is not clean. Execute "go mod tidy && go mod vendor" locally in the 'generator' folder and commit changes to fix an issue'; exit 1; } - - - name: Check Generator GO format - working-directory: generator - run: | - go fmt -x ./... - git diff --exit-code || { echo 'Go sources need to be formated. Execute "go fmt -x ./..." locally in the 'generator' folder and commit changes to fix an issue'; exit 1; } - - name: Upload Json schemas - uses: actions/upload-artifact@v2 - with: - name: devfile-json-schema - path: schemas/latest/devfile.json + - uses: actions/checkout@v2 + + - name: Setup Go environment + uses: actions/setup-go@v2.1.3 + with: + # The Go version to download (if necessary) and use. Supports semver spec and ranges. + go-version: 1.18 + + - name: Generate Go sources, CRDs and schemas + run: | + ./docker-run.sh ./build.sh + if [[ ! -z $(git status -s) ]] + then + echo 'Command `./docker-run.sh ./build.sh` did introduce changes, which should not be the case if it had been run as part of the PR. Please run it locally and check in the results as part of your PR.' + git --no-pager diff + exit 1 + fi + + - name: Validate samples against schemas + run: ./docker-run.sh ./validate-samples.sh + + - name: Run GO tests + run: go test -coverprofile cover.out -v ./... + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2.1.0 + + - name: Check typescript model generation + run: ./build/typescript-model/generate.sh + + - name: Check GO mod state + run: | + go mod tidy + go mod vendor + git diff --exit-code || { echo 'Go mod is not clean. Execute "go mod tidy && go mod vendor" locally and commit changes to fix an issue'; exit 1; } + + - name: Check GO format + run: | + go fmt -x ./... + git diff --exit-code || { echo 'Go sources need to be formatted. Execute "go fmt -x ./..." locally and commit changes to fix an issue'; exit 1; } + + - name: Check Generator GO mod state + working-directory: generator + run: | + go mod tidy + go mod vendor + git diff --exit-code || { echo 'Go mod is not clean. Execute "go mod tidy && go mod vendor" locally in the 'generator' folder and commit changes to fix an issue'; exit 1; } + + - name: Check Generator GO format + working-directory: generator + run: | + go fmt -x ./... + git diff --exit-code || { echo 'Go sources need to be formatted. Execute "go fmt -x ./..." locally in the 'generator' folder and commit changes to fix an issue'; exit 1; } + - name: Upload Json schemas + uses: actions/upload-artifact@v2 + with: + name: devfile-json-schema + path: schemas/latest/devfile.json publish-next-json-schema: if: success() && github.event_name == 'push' @@ -79,36 +79,49 @@ jobs: - name: Checkout devfile docs uses: actions/checkout@v2 with: - repository: devfile/docs + repository: devfile/devfile-web persist-credentials: false - path: docs-repo + path: devfile-web-repo + - name: Checkout devfile api uses: actions/checkout@v2 with: path: api-repo - - name: Download Json Schema - uses: actions/download-artifact@v2 - with: - name: devfile-json-schema - - name: Overwrite Next Json Schema in Docs - run: cp -f devfile.json docs-repo/docs/modules/user-guide/attachments/jsonschemas/next/devfile.json - - name: Push to the devfile/docs repo - working-directory: docs-repo/ + + - name: Get the version being published + id: get_version + run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt) + + - name: Publish the new version on devfile-web run: | - if [ "$(git status -s)" == "" ] - then - echo "Nothing to commit, Json schema didn't change" + py devfile-web-repo/python/src/api_workflow/api_workflow.py --version ${{ steps.get_version.outputs.version }} --devfile-schema api-repo/schemas/latest/devfile.json --release + + - name: Push to the devfile/devfile-web repo + working-directory: devfile-web-repo/ + run: | + # Install dependencies to format the commit + yarn install + + # Format the commit + yarn nx format:write + + # Lint the commit + yarn nx affected --target=lint + yarn nx format:check + + # Don't commit if there are no changes + if [ "$(git status -s)" == "" ]; then + echo "Nothing to commit" exit 0 fi - + lastCommit="$(cd ../api-repo; git log -1 --format=%H)" lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)" lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)" - + git config --global user.email "${lastCommitterEmail}" git config --global user.name "${lastCommitterName}" - - git add docs/modules/user-guide/attachments/jsonschemas/next/devfile.json - git commit -m "Update devfile schema based on devfile/api@${lastCommit}" - git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/docs" - + + git add . + git commit -asm "Update devfile schema based on devfile/api@${lastCommit}" + git push "https://devfile-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web" diff --git a/.github/workflows/release-schema.yaml b/.github/workflows/release-schema.yaml index c034f3409..27c500d88 100644 --- a/.github/workflows/release-schema.yaml +++ b/.github/workflows/release-schema.yaml @@ -9,71 +9,51 @@ jobs: release-json-schema: runs-on: ubuntu-latest steps: - - name: Checkout devfile docs + - name: Checkout devfile/devfile-web uses: actions/checkout@v2 with: - repository: devfile/docs + repository: devfile/devfile-web persist-credentials: false - path: docs-repo - - name: Checkout devfile api + path: devfile-web-repo + + - name: Checkout devfile/api uses: actions/checkout@v2 with: path: api-repo + - name: Get the version being released id: get_version run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt) - - name: Overwrite Stable Json Schema in Docs if needed - run: | - if [ ! -f docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/jsonSchemaVersion.txt ]; then - # Stable version doesn't currently exist, so just copy over the schema we're releasing - mkdir -p docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable - cp -f api-repo/schemas/latest/{devfile.json,jsonSchemaVersion.txt} \ - docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/ - exit 0 - fi - - # Parse the schema version that's being released - IFS='.' read -a semver <<< "${{ steps.get_version.outputs.VERSION }}" - MAJOR=${semver[0]} - MINOR=${semver[1]} - BUGFIX=${semver[2]} - - # Parse the version currently set to stable - stableVersion=`cat docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/jsonSchemaVersion.txt` - IFS='.' read -a stableSemVer <<< "$stableVersion" - stableMajor=${stableSemVer[0]} - stableMinor=${stableSemVer[1]} - stableBugfix=$(echo ${stableSemVer[2]} | awk -F '-' '{print $1}') - # Compare the two versions, only update stable if needed - if ((stableMajor <= MAJOR)) && ((stableMinor <= MINOR)) && ((stableBugfix <= BUGFIX)); then - cp -f api-repo/schemas/latest/{devfile.json,jsonSchemaVersion.txt} \ - docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/ - else - echo "::warning::Current stable schema version is newer than the schema version being released, so the stable schema will not be updated." - fi - - name: Copy released Json Schema to Docs + - name: Release new version on devfile-web run: | - mkdir -p docs-repo/docs/modules/user-guide/attachments/jsonschemas/${{ steps.get_version.outputs.VERSION }} && \ - cp -f api-repo/schemas/latest/devfile.json \ - docs-repo/docs/modules/user-guide/attachments/jsonschemas/${{ steps.get_version.outputs.VERSION }}/devfile.json - - name: Push to the devfile/docs repo - working-directory: docs-repo/ + py devfile-web-repo/python/src/api_workflow/api_workflow.py --version ${{ steps.get_version.outputs.version }} --devfile-schema api-repo/schemas/latest/devfile.json --release + + - name: Push to the devfile/devfile-web repo + working-directory: devfile-web-repo/ run: | - if [ "$(git status -s)" == "" ] - then - echo "Nothing to commit, Json schema didn't change" + yarn install + + # Format the commit + yarn nx format:write + + # Lint the commit + yarn nx affected --target=lint + yarn nx format:check + + # Don't commit if there are no changes + if [ "$(git status -s)" == "" ]; then + echo "Nothing to commit" exit 0 fi - + lastCommit="$(cd ../api-repo; git log -1 --format=%H)" lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)" lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)" - + git config --global user.email "${lastCommitterEmail}" git config --global user.name "${lastCommitterName}" - - git add --all - git commit -m "Update devfile schema based on devfile/api@${lastCommit}" - git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/docs" - + + git add . + git commit -asm "Update devfile schema based on devfile/api@${lastCommit}" + git push "https://devfile-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web"