Skip to content

Commit 2609b35

Browse files
authored
Update landing page release/publish scripts (#921)
Signed-off-by: Paul Schultz <[email protected]>
1 parent 31045fa commit 2609b35

File tree

2 files changed

+122
-129
lines changed

2 files changed

+122
-129
lines changed

.github/workflows/ci.yaml

Lines changed: 93 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,73 +3,73 @@ name: CI
33
# Triggers the workflow on push or pull request events but only for the main branch
44
on:
55
push:
6-
branches: [ main ]
6+
branches: [main]
77
pull_request:
8-
branches: [ main ]
8+
branches: [main]
99

1010
jobs:
1111
build-and-validate:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- uses: actions/checkout@v2
16-
17-
- name: Setup Go environment
18-
uses: actions/[email protected]
19-
with:
20-
# The Go version to download (if necessary) and use. Supports semver spec and ranges.
21-
go-version: 1.18
22-
23-
- name: Generate Go sources, CRDs and schemas
24-
run: |
25-
./docker-run.sh ./build.sh
26-
if [[ ! -z $(git status -s) ]]
27-
then
28-
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.'
29-
git --no-pager diff
30-
exit 1
31-
fi
32-
33-
- name: Validate samples against schemas
34-
run: ./docker-run.sh ./validate-samples.sh
35-
36-
- name: Run GO tests
37-
run: go test -coverprofile cover.out -v ./...
38-
39-
- name: Upload coverage to Codecov
40-
uses: codecov/[email protected]
41-
42-
- name: Check typescript model generation
43-
run: ./build/typescript-model/generate.sh
44-
45-
- name: Check GO mod state
46-
run: |
47-
go mod tidy
48-
go mod vendor
49-
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; }
50-
51-
- name: Check GO format
52-
run: |
53-
go fmt -x ./...
54-
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; }
55-
56-
- name: Check Generator GO mod state
57-
working-directory: generator
58-
run: |
59-
go mod tidy
60-
go mod vendor
61-
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; }
62-
63-
- name: Check Generator GO format
64-
working-directory: generator
65-
run: |
66-
go fmt -x ./...
67-
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; }
68-
- name: Upload Json schemas
69-
uses: actions/upload-artifact@v2
70-
with:
71-
name: devfile-json-schema
72-
path: schemas/latest/devfile.json
15+
- uses: actions/checkout@v2
16+
17+
- name: Setup Go environment
18+
uses: actions/[email protected]
19+
with:
20+
# The Go version to download (if necessary) and use. Supports semver spec and ranges.
21+
go-version: 1.18
22+
23+
- name: Generate Go sources, CRDs and schemas
24+
run: |
25+
./docker-run.sh ./build.sh
26+
if [[ ! -z $(git status -s) ]]
27+
then
28+
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.'
29+
git --no-pager diff
30+
exit 1
31+
fi
32+
33+
- name: Validate samples against schemas
34+
run: ./docker-run.sh ./validate-samples.sh
35+
36+
- name: Run GO tests
37+
run: go test -coverprofile cover.out -v ./...
38+
39+
- name: Upload coverage to Codecov
40+
uses: codecov/[email protected]
41+
42+
- name: Check typescript model generation
43+
run: ./build/typescript-model/generate.sh
44+
45+
- name: Check GO mod state
46+
run: |
47+
go mod tidy
48+
go mod vendor
49+
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; }
50+
51+
- name: Check GO format
52+
run: |
53+
go fmt -x ./...
54+
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; }
55+
56+
- name: Check Generator GO mod state
57+
working-directory: generator
58+
run: |
59+
go mod tidy
60+
go mod vendor
61+
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; }
62+
63+
- name: Check Generator GO format
64+
working-directory: generator
65+
run: |
66+
go fmt -x ./...
67+
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; }
68+
- name: Upload Json schemas
69+
uses: actions/upload-artifact@v2
70+
with:
71+
name: devfile-json-schema
72+
path: schemas/latest/devfile.json
7373

7474
publish-next-json-schema:
7575
if: success() && github.event_name == 'push'
@@ -79,36 +79,49 @@ jobs:
7979
- name: Checkout devfile docs
8080
uses: actions/checkout@v2
8181
with:
82-
repository: devfile/docs
82+
repository: devfile/devfile-web
8383
persist-credentials: false
84-
path: docs-repo
84+
path: devfile-web-repo
85+
8586
- name: Checkout devfile api
8687
uses: actions/checkout@v2
8788
with:
8889
path: api-repo
89-
- name: Download Json Schema
90-
uses: actions/download-artifact@v2
91-
with:
92-
name: devfile-json-schema
93-
- name: Overwrite Next Json Schema in Docs
94-
run: cp -f devfile.json docs-repo/docs/modules/user-guide/attachments/jsonschemas/next/devfile.json
95-
- name: Push to the devfile/docs repo
96-
working-directory: docs-repo/
90+
91+
- name: Get the version being published
92+
id: get_version
93+
run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt)
94+
95+
- name: Publish the new version on devfile-web
9796
run: |
98-
if [ "$(git status -s)" == "" ]
99-
then
100-
echo "Nothing to commit, Json schema didn't change"
97+
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
98+
99+
- name: Push to the devfile/devfile-web repo
100+
working-directory: devfile-web-repo/
101+
run: |
102+
# Install dependencies to format the commit
103+
yarn install
104+
105+
# Format the commit
106+
yarn nx format:write
107+
108+
# Lint the commit
109+
yarn nx affected --target=lint
110+
yarn nx format:check
111+
112+
# Don't commit if there are no changes
113+
if [ "$(git status -s)" == "" ]; then
114+
echo "Nothing to commit"
101115
exit 0
102116
fi
103-
117+
104118
lastCommit="$(cd ../api-repo; git log -1 --format=%H)"
105119
lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)"
106120
lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)"
107-
121+
108122
git config --global user.email "${lastCommitterEmail}"
109123
git config --global user.name "${lastCommitterName}"
110-
111-
git add docs/modules/user-guide/attachments/jsonschemas/next/devfile.json
112-
git commit -m "Update devfile schema based on devfile/api@${lastCommit}"
113-
git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/docs"
114-
124+
125+
git add .
126+
git commit -asm "Update devfile schema based on devfile/api@${lastCommit}"
127+
git push "https://devfile-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web"

.github/workflows/release-schema.yaml

Lines changed: 29 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,51 @@ jobs:
99
release-json-schema:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Checkout devfile docs
12+
- name: Checkout devfile/devfile-web
1313
uses: actions/checkout@v2
1414
with:
15-
repository: devfile/docs
15+
repository: devfile/devfile-web
1616
persist-credentials: false
17-
path: docs-repo
18-
- name: Checkout devfile api
17+
path: devfile-web-repo
18+
19+
- name: Checkout devfile/api
1920
uses: actions/checkout@v2
2021
with:
2122
path: api-repo
23+
2224
- name: Get the version being released
2325
id: get_version
2426
run: echo ::set-output name=version::$(cat api-repo/schemas/latest/jsonSchemaVersion.txt)
25-
- name: Overwrite Stable Json Schema in Docs if needed
26-
run: |
27-
if [ ! -f docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/jsonSchemaVersion.txt ]; then
28-
# Stable version doesn't currently exist, so just copy over the schema we're releasing
29-
mkdir -p docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable
30-
cp -f api-repo/schemas/latest/{devfile.json,jsonSchemaVersion.txt} \
31-
docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/
32-
exit 0
33-
fi
34-
35-
# Parse the schema version that's being released
36-
IFS='.' read -a semver <<< "${{ steps.get_version.outputs.VERSION }}"
37-
MAJOR=${semver[0]}
38-
MINOR=${semver[1]}
39-
BUGFIX=${semver[2]}
40-
41-
# Parse the version currently set to stable
42-
stableVersion=`cat docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/jsonSchemaVersion.txt`
43-
IFS='.' read -a stableSemVer <<< "$stableVersion"
44-
stableMajor=${stableSemVer[0]}
45-
stableMinor=${stableSemVer[1]}
46-
stableBugfix=$(echo ${stableSemVer[2]} | awk -F '-' '{print $1}')
4727

48-
# Compare the two versions, only update stable if needed
49-
if ((stableMajor <= MAJOR)) && ((stableMinor <= MINOR)) && ((stableBugfix <= BUGFIX)); then
50-
cp -f api-repo/schemas/latest/{devfile.json,jsonSchemaVersion.txt} \
51-
docs-repo/docs/modules/user-guide/attachments/jsonschemas/stable/
52-
else
53-
echo "::warning::Current stable schema version is newer than the schema version being released, so the stable schema will not be updated."
54-
fi
55-
- name: Copy released Json Schema to Docs
28+
- name: Release new version on devfile-web
5629
run: |
57-
mkdir -p docs-repo/docs/modules/user-guide/attachments/jsonschemas/${{ steps.get_version.outputs.VERSION }} && \
58-
cp -f api-repo/schemas/latest/devfile.json \
59-
docs-repo/docs/modules/user-guide/attachments/jsonschemas/${{ steps.get_version.outputs.VERSION }}/devfile.json
60-
- name: Push to the devfile/docs repo
61-
working-directory: docs-repo/
30+
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
31+
32+
- name: Push to the devfile/devfile-web repo
33+
working-directory: devfile-web-repo/
6234
run: |
63-
if [ "$(git status -s)" == "" ]
64-
then
65-
echo "Nothing to commit, Json schema didn't change"
35+
yarn install
36+
37+
# Format the commit
38+
yarn nx format:write
39+
40+
# Lint the commit
41+
yarn nx affected --target=lint
42+
yarn nx format:check
43+
44+
# Don't commit if there are no changes
45+
if [ "$(git status -s)" == "" ]; then
46+
echo "Nothing to commit"
6647
exit 0
6748
fi
68-
49+
6950
lastCommit="$(cd ../api-repo; git log -1 --format=%H)"
7051
lastCommitterName="$(cd ../api-repo; git log -1 --format=%an)"
7152
lastCommitterEmail="$(cd ../api-repo; git log -1 --format=%ae)"
72-
53+
7354
git config --global user.email "${lastCommitterEmail}"
7455
git config --global user.name "${lastCommitterName}"
75-
76-
git add --all
77-
git commit -m "Update devfile schema based on devfile/api@${lastCommit}"
78-
git push "https://devfile-ci-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/docs"
79-
56+
57+
git add .
58+
git commit -asm "Update devfile schema based on devfile/api@${lastCommit}"
59+
git push "https://devfile-robot:${{secrets.DOCS_UPDATE_SECRET}}@github.com/devfile/devfile-web"

0 commit comments

Comments
 (0)