Skip to content

Update landing page release/publish scripts #921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 93 additions & 80 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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/[email protected]

- 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/[email protected]
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/[email protected]

- 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'
Expand All @@ -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"
78 changes: 29 additions & 49 deletions .github/workflows/release-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"