From c22c9ae767fdc454c55070e2428637e20e85e810 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 15:30:49 +0300 Subject: [PATCH 01/33] wip --- .github/workflows/gui-ci.yml | 5 +++++ build/workflow.js | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index d30e61be05..b649aad2f9 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -10,7 +10,12 @@ name: GUI CI - develop - unstable - stable + - wip/db/nightly-release pull_request: {} + schedule: + cron: >- + "0 7 * * 2-6" # 7am (UTC) from Tuesday to Saturday (i.e. after every + workday) jobs: info: name: Build Info diff --git a/build/workflow.js b/build/workflow.js index 4d30080591..894065d8c2 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -451,9 +451,12 @@ let workflow = { name : "GUI CI", on: { push: { - branches: ['develop','unstable','stable'] + branches: ['develop','unstable','stable','wip/db/nightly-release'], }, - pull_request: {} + pull_request: {}, + schedule: { + cron: '"0 7 * * 2-6" # 7am (UTC) from Tuesday to Saturday (i.e. after every workday)', + } }, jobs: { info: job_on_macos("Build Info", [ From b46ca87a597981b6321f3db3a5a683a2e4a5a4e3 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 15:34:32 +0300 Subject: [PATCH 02/33] wip --- .github/workflows/gui-ci.yml | 6 +++--- build/workflow.js | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index b649aad2f9..7e541b3805 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -13,9 +13,9 @@ name: GUI CI - wip/db/nightly-release pull_request: {} schedule: - cron: >- - "0 7 * * 2-6" # 7am (UTC) from Tuesday to Saturday (i.e. after every - workday) + - cron: >- + "0 7 * * 2-6" # 7am (UTC) from Tuesday to Saturday (i.e. after every + workday) jobs: info: name: Build Info diff --git a/build/workflow.js b/build/workflow.js index 894065d8c2..77658acd95 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -454,9 +454,11 @@ let workflow = { branches: ['develop','unstable','stable','wip/db/nightly-release'], }, pull_request: {}, - schedule: { - cron: '"0 7 * * 2-6" # 7am (UTC) from Tuesday to Saturday (i.e. after every workday)', - } + schedule: [ + { + cron: '"0 7 * * 2-6" # 7am (UTC) from Tuesday to Saturday (i.e. after every workday)', + }, + ] }, jobs: { info: job_on_macos("Build Info", [ From d23b18b7d42045dd1debb0db547b4d55cb231dfe Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 15:39:12 +0300 Subject: [PATCH 03/33] wip --- .github/workflows/gui-ci.yml | 4 +--- build/workflow.js | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index 7e541b3805..de43834fce 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -13,9 +13,7 @@ name: GUI CI - wip/db/nightly-release pull_request: {} schedule: - - cron: >- - "0 7 * * 2-6" # 7am (UTC) from Tuesday to Saturday (i.e. after every - workday) + - cron: 0 7 * * 2-6 jobs: info: name: Build Info diff --git a/build/workflow.js b/build/workflow.js index 77658acd95..cb49092f5a 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -456,7 +456,7 @@ let workflow = { pull_request: {}, schedule: [ { - cron: '"0 7 * * 2-6" # 7am (UTC) from Tuesday to Saturday (i.e. after every workday)', + cron: '0 7 * * 2-6' }, ] }, From 36984d608350b915024bfa739acd71bfafbcc0e1 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 19:22:26 +0300 Subject: [PATCH 04/33] feat: nightly version --- .github/workflows/gui-ci.yml | 2 ++ build/release.js | 31 +++++++++++++++++++++++++++---- build/workflow.js | 3 +++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index de43834fce..4a464e49e6 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -3,6 +3,8 @@ # DO NOT CHANGE THIS FILE. IT WAS GENERATED FROM 'build/workflow.js'. READ DOCS THERE TO LEARN MORE. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +env: + CI_EVENT_NAME: ${{ github.event_name }} name: GUI CI 'on': push: diff --git a/build/release.js b/build/release.js index 82ff0f9447..3475cc148c 100644 --- a/build/release.js +++ b/build/release.js @@ -24,16 +24,25 @@ const CHANGELOG_FILE = path.join(paths.root,CHANGELOG_FILE_NAME) class NextReleaseVersion { /// Version used for config files when building the package with "next version" in changelog. toString() { - return "0.0.0" + if (this.isNightly()) { + return this.prevVersion.toString() + } else { + return "0.0.0" + } } isPrerelease() { return true } + + isNightly() { + return process.env.CI_EVENT_NAME === 'schedule' + } + } class Version { - constructor(major,minor,patch,tag,tagVersion,rcTag,rcTagVersion) { + constructor(major,minor,patch,tag,tagVersion,rcTag,rcTagVersion,year,month,day) { this.major = major this.minor = minor this.patch = patch @@ -41,6 +50,9 @@ class Version { this.tagVersion = parseInt(tagVersion) this.rcTag = rcTag this.rcTagVersion = rcTagVersion + this.year = year + this.month = month + this.day = day } lt(that) { @@ -59,6 +71,10 @@ class Version { if (this.tag) { return true } else { return false } } + isNightly() { + return process.env.CI_EVENT_NAME === 'schedule' + } + toString() { let suffix = '' if (this.tag) { @@ -67,6 +83,9 @@ class Version { suffix += `.${this.rcTag}.${this.rcTagVersion}` } } + if (this.isNightly()) { + suffix += `-nightly-${this.year}-${this.month}-${this.day}` + } return `${this.major}.${this.minor}.${this.patch}${suffix}` } } @@ -136,6 +155,7 @@ function changelogSections() { function changelogEntries() { let sections = changelogSections() + let nextRelease = new NextReleaseVersion let entries = [] let firstSection = true for (let section of sections) { @@ -143,7 +163,7 @@ function changelogEntries() { let header = section.substring(0,splitPoint) let body = section.substring(splitPoint).trim() if (firstSection && header.startsWith(' Next Release')) { - let version = new NextReleaseVersion + let version = nextRelease entries.push(new ChangelogEntry(version,body)) } else { let headerReg = /^ Enso (?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)(-(?alpha|beta|rc)\.(?[0-9]+))?(.(?rc)\.(?[0-9]+))? \((?[0-9][0-9][0-9][0-9])-(?[0-9][0-9])-(?[0-9][0-9])\)/ @@ -152,7 +172,10 @@ function changelogEntries() { throw `Improper changelog entry header: '${header}'. See the 'CHANGELOG_TEMPLATE.md' for details.` } let grps = match.groups - let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion) + let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion,grps.year,grps.month,grps.day) + if (nextRelease.prevVersion === undefined) { + nextRelease.prevVersion = version + } entries.push(new ChangelogEntry(version,body)) } firstSection = false diff --git a/build/workflow.js b/build/workflow.js index cb49092f5a..cf819db61a 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -448,6 +448,9 @@ let releaseCondition = `github.ref == 'refs/heads/unstable' || github.ref == 're let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_BUILD}') || contains(github.event.head_commit.message,'${FLAG_FORCE_CI_BUILD}') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (${releaseCondition})` let workflow = { + env: { + CI_EVENT_NAME: "${{ github.event_name }}", + }, name : "GUI CI", on: { push: { From bb28bec1a9f7a099418ba4db82f267f914a921f1 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 19:53:10 +0300 Subject: [PATCH 05/33] feat: setup env --- .github/workflows/gui-ci.yml | 42 +++++++++++++++++++++++++++++------- build/release.js | 4 ++-- build/workflow.js | 12 ++++++----- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index 4a464e49e6..8f78eba342 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -3,8 +3,6 @@ # DO NOT CHANGE THIS FILE. IT WAS GENERATED FROM 'build/workflow.js'. READ DOCS THERE TO LEARN MORE. # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -env: - CI_EVENT_NAME: ${{ github.event_name }} name: GUI CI 'on': push: @@ -45,6 +43,11 @@ jobs: id: changelog run: |2- + if [[ ${{ github.event_name }} == 'schedule' ]]; + then + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + fi + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" @@ -66,7 +69,9 @@ jobs: run: >- if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi - if: github.base_ref == 'unstable' || github.base_ref == 'stable' + if: >- + env.CI_BUILD_NIGHTLY == 'true' || github.base_ref == 'unstable' || + github.base_ref == 'stable' - name: Get list of changed files id: changed_files run: |2- @@ -286,6 +291,11 @@ jobs: id: changelog run: |2- + if [[ ${{ github.event_name }} == 'schedule' ]]; + then + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + fi + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" @@ -417,8 +427,8 @@ jobs: contains(github.event.pull_request.body,'[ci build]') || contains(github.event.head_commit.message,'[ci build]') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref - == 'stable' || (github.ref == 'refs/heads/unstable' || github.ref == - 'refs/heads/stable') + == 'stable' || (env.CI_BUILD_NIGHTLY == 'true' || github.ref == + 'refs/heads/unstable' || github.ref == 'refs/heads/stable') release_to_github: name: GitHub Release runs-on: ${{ matrix.os }} @@ -437,6 +447,11 @@ jobs: id: changelog run: |2- + if [[ ${{ github.event_name }} == 'schedule' ]]; + then + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + fi + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" @@ -452,7 +467,9 @@ jobs: run: >- if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi - if: github.base_ref == 'unstable' || github.base_ref == 'stable' + if: >- + env.CI_BUILD_NIGHTLY == 'true' || github.base_ref == 'unstable' || + github.base_ref == 'stable' - name: Install Prettier run: npm install --save-dev --save-exact prettier - name: Pretty print changelog. @@ -468,7 +485,9 @@ jobs: body: ${{fromJson(steps.changelog.outputs.content).body}} prerelease: ${{fromJson(steps.changelog.outputs.content).prerelease}} draft: true - if: github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable' + if: >- + env.CI_BUILD_NIGHTLY == 'true' || github.ref == 'refs/heads/unstable' || + github.ref == 'refs/heads/stable' needs: - version_assertions - lint @@ -492,6 +511,11 @@ jobs: id: changelog run: |2- + if [[ ${{ github.event_name }} == 'schedule' ]]; + then + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + fi + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" @@ -532,7 +556,9 @@ jobs: aws s3 cp ./artifacts/content/assets/wasm_imports.js.gz s3://ensocdn/ide/${{fromJson(steps.changelog.outputs.content).version}}/wasm_imports.js.gz --profile s3-upload --acl public-read --content-encoding gzip - if: github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable' + if: >- + env.CI_BUILD_NIGHTLY == 'true' || github.ref == 'refs/heads/unstable' || + github.ref == 'refs/heads/stable' needs: - version_assertions - lint diff --git a/build/release.js b/build/release.js index 3475cc148c..08ba9fbc72 100644 --- a/build/release.js +++ b/build/release.js @@ -36,7 +36,7 @@ class NextReleaseVersion { } isNightly() { - return process.env.CI_EVENT_NAME === 'schedule' + if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } } } @@ -72,7 +72,7 @@ class Version { } isNightly() { - return process.env.CI_EVENT_NAME === 'schedule' + if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } } toString() { diff --git a/build/workflow.js b/build/workflow.js index cf819db61a..9b69fb7fb1 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -297,6 +297,11 @@ let getCurrentReleaseChangelogInfo = { name: 'Read changelog info', id: 'changelog', run: ` + if [[ \$\{\{ github.event_name \}\} == 'schedule' ]]; + then + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + fi + echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV node ./run ci-gen --skip-version-validation content=\`cat CURRENT_RELEASE_CHANGELOG.json\` echo "::set-output name=content::$content" @@ -413,7 +418,7 @@ let assertReleaseDoNotExists = [ { name: 'Fail if release already exists', run: 'if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi', - if: `github.base_ref == 'unstable' || github.base_ref == 'stable'` + if: `env.CI_BUILD_NIGHTLY == 'true' || github.base_ref == 'unstable' || github.base_ref == 'stable'` } ] @@ -438,7 +443,7 @@ let assertions = list( /// Make a release only if it was a push to 'unstable' or 'stable'. Even if it was a pull request /// FROM these branches, the `github.ref` will be different. -let releaseCondition = `github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'` +let releaseCondition = `env.CI_BUILD_NIGHTLY == 'true' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'` /// Make a full build if one of the following conditions is true: /// 1. There was a `FLAG_FORCE_CI_BUILD` flag set in the commit message (see its docs for more info). @@ -448,9 +453,6 @@ let releaseCondition = `github.ref == 'refs/heads/unstable' || github.ref == 're let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_BUILD}') || contains(github.event.head_commit.message,'${FLAG_FORCE_CI_BUILD}') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (${releaseCondition})` let workflow = { - env: { - CI_EVENT_NAME: "${{ github.event_name }}", - }, name : "GUI CI", on: { push: { From 494b148ba703950e9dcb1c4adaf4436f0565bfc1 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 20:03:45 +0300 Subject: [PATCH 06/33] wip --- .github/workflows/gui-ci.yml | 6 +++--- build/workflow.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index 8f78eba342..b665952c67 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -427,7 +427,7 @@ jobs: contains(github.event.pull_request.body,'[ci build]') || contains(github.event.head_commit.message,'[ci build]') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref - == 'stable' || (env.CI_BUILD_NIGHTLY == 'true' || github.ref == + == 'stable' || (github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable') release_to_github: name: GitHub Release @@ -486,7 +486,7 @@ jobs: prerelease: ${{fromJson(steps.changelog.outputs.content).prerelease}} draft: true if: >- - env.CI_BUILD_NIGHTLY == 'true' || github.ref == 'refs/heads/unstable' || + github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable' needs: - version_assertions @@ -557,7 +557,7 @@ jobs: s3://ensocdn/ide/${{fromJson(steps.changelog.outputs.content).version}}/wasm_imports.js.gz --profile s3-upload --acl public-read --content-encoding gzip if: >- - env.CI_BUILD_NIGHTLY == 'true' || github.ref == 'refs/heads/unstable' || + github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable' needs: - version_assertions diff --git a/build/workflow.js b/build/workflow.js index 9b69fb7fb1..4de1cad03b 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -443,7 +443,7 @@ let assertions = list( /// Make a release only if it was a push to 'unstable' or 'stable'. Even if it was a pull request /// FROM these branches, the `github.ref` will be different. -let releaseCondition = `env.CI_BUILD_NIGHTLY == 'true' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'` +let releaseCondition = `github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'` /// Make a full build if one of the following conditions is true: /// 1. There was a `FLAG_FORCE_CI_BUILD` flag set in the commit message (see its docs for more info). From 9c0b5d6ba4241c79a4179b28eae28c8fc8386b15 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 20:17:06 +0300 Subject: [PATCH 07/33] misc: [ci-build] From 823fe8b5d5de9cf0852b4da6203c0243ad6acb0c Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 20:22:09 +0300 Subject: [PATCH 08/33] wip: force ci build --- .github/workflows/gui-ci.yml | 2 +- build/workflow.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index b665952c67..c3b991236d 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -428,7 +428,7 @@ jobs: contains(github.event.head_commit.message,'[ci build]') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (github.event_name == 'schedule' || github.ref == - 'refs/heads/unstable' || github.ref == 'refs/heads/stable') + 'refs/heads/unstable' || github.ref == 'refs/heads/stable') || true release_to_github: name: GitHub Release runs-on: ${{ matrix.os }} diff --git a/build/workflow.js b/build/workflow.js index 4de1cad03b..49e5d25ad1 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -450,7 +450,7 @@ let releaseCondition = `github.event_name == 'schedule' || github.ref == 'refs/h /// 2. It was a pull request to the 'unstable', or the 'stable' branch. /// 3. It was a commit to the 'develop' branch. /// Otherwise, perform a simplified (faster) build only. -let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_BUILD}') || contains(github.event.head_commit.message,'${FLAG_FORCE_CI_BUILD}') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (${releaseCondition})` +let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_BUILD}') || contains(github.event.head_commit.message,'${FLAG_FORCE_CI_BUILD}') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (${releaseCondition}) || true` let workflow = { name : "GUI CI", From 97411e729fad918fbd9cd74c2df5a993547ddc77 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 21:11:07 +0300 Subject: [PATCH 09/33] feat: setup env step --- .github/workflows/gui-ci.yml | 36 ++++++++++++++++++++++++++++-------- build/workflow.js | 17 ++++++++++++++--- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index c3b991236d..bb9e084c7e 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -39,8 +39,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v1 - - name: Read changelog info - id: changelog + - name: Setup environment run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -48,6 +47,12 @@ jobs: echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV fi echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + + shell: bash + - name: Read changelog info + id: changelog + run: |2- + node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" @@ -287,8 +292,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v1 - - name: Read changelog info - id: changelog + - name: Setup environment run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -296,6 +300,12 @@ jobs: echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV fi echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + + shell: bash + - name: Read changelog info + id: changelog + run: |2- + node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" @@ -443,8 +453,7 @@ jobs: uses: actions/download-artifact@v2 with: path: artifacts - - name: Read changelog info - id: changelog + - name: Setup environment run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -452,6 +461,12 @@ jobs: echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV fi echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + + shell: bash + - name: Read changelog info + id: changelog + run: |2- + node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" @@ -507,8 +522,7 @@ jobs: uses: actions/download-artifact@v2 with: path: artifacts - - name: Read changelog info - id: changelog + - name: Setup environment run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -516,6 +530,12 @@ jobs: echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV fi echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + + shell: bash + - name: Read changelog info + id: changelog + run: |2- + node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" diff --git a/build/workflow.js b/build/workflow.js index 49e5d25ad1..4f42670d9f 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -293,15 +293,22 @@ let getListOfChangedFiles = { // === Changelog === // ================= -let getCurrentReleaseChangelogInfo = { - name: 'Read changelog info', - id: 'changelog', +let setupEnvironment = { + name: 'Setup environment', run: ` if [[ \$\{\{ github.event_name \}\} == 'schedule' ]]; then echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV fi echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + `, + shell: 'bash' +} + +let getCurrentReleaseChangelogInfo = { + name: 'Read changelog info', + id: 'changelog', + run: ` node ./run ci-gen --skip-version-validation content=\`cat CURRENT_RELEASE_CHANGELOG.json\` echo "::set-output name=content::$content" @@ -470,6 +477,7 @@ let workflow = { dumpGitHubContext ]), version_assertions: job_on_macos("Assertions", [ + setupEnvironment, getCurrentReleaseChangelogInfo, assertions ]), @@ -505,6 +513,7 @@ let workflow = { buildOnMacOS, ]), build: job_on_all_platforms("Build", [ + setupEnvironment, getCurrentReleaseChangelogInfo, installNode, installTypeScript, @@ -522,6 +531,7 @@ let workflow = { ],{if:buildCondition}), release_to_github: job_on_macos("GitHub Release", [ downloadArtifacts, + setupEnvironment, getCurrentReleaseChangelogInfo, // This assertion is checked earlier, but we should double-check it in case several // CI jobs wil be run on this branch and a release was created when this workflow was @@ -533,6 +543,7 @@ let workflow = { }), release_to_cdn: job_on_ubuntu_18_04("CDN Release", [ downloadArtifacts, + setupEnvironment, getCurrentReleaseChangelogInfo, prepareAwsSessionCDN, uploadToCDN('index.js.gz','style.css','ide.wasm','wasm_imports.js.gz'), From b87f9bfcedd8068cf6d65d4da4116b4ad32c69d2 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 2 Sep 2021 22:25:31 +0300 Subject: [PATCH 10/33] wip: force release --- .github/workflows/gui-ci.yml | 6 +++--- build/workflow.js | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index bb9e084c7e..82de4360d8 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -438,7 +438,7 @@ jobs: contains(github.event.head_commit.message,'[ci build]') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (github.event_name == 'schedule' || github.ref == - 'refs/heads/unstable' || github.ref == 'refs/heads/stable') || true + 'refs/heads/unstable' || github.ref == 'refs/heads/stable' || true) release_to_github: name: GitHub Release runs-on: ${{ matrix.os }} @@ -502,7 +502,7 @@ jobs: draft: true if: >- github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || - github.ref == 'refs/heads/stable' + github.ref == 'refs/heads/stable' || true needs: - version_assertions - lint @@ -578,7 +578,7 @@ jobs: --profile s3-upload --acl public-read --content-encoding gzip if: >- github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || - github.ref == 'refs/heads/stable' + github.ref == 'refs/heads/stable' || true needs: - version_assertions - lint diff --git a/build/workflow.js b/build/workflow.js index 4f42670d9f..e64db30e04 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -450,14 +450,14 @@ let assertions = list( /// Make a release only if it was a push to 'unstable' or 'stable'. Even if it was a pull request /// FROM these branches, the `github.ref` will be different. -let releaseCondition = `github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'` +let releaseCondition = `github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable' || true` /// Make a full build if one of the following conditions is true: /// 1. There was a `FLAG_FORCE_CI_BUILD` flag set in the commit message (see its docs for more info). /// 2. It was a pull request to the 'unstable', or the 'stable' branch. /// 3. It was a commit to the 'develop' branch. /// Otherwise, perform a simplified (faster) build only. -let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_BUILD}') || contains(github.event.head_commit.message,'${FLAG_FORCE_CI_BUILD}') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (${releaseCondition}) || true` +let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_BUILD}') || contains(github.event.head_commit.message,'${FLAG_FORCE_CI_BUILD}') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (${releaseCondition})` let workflow = { name : "GUI CI", From 04df3c5b63883da35e7619470f68a06df4788865 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 11:59:36 +0300 Subject: [PATCH 11/33] feat: nightly engine --- .github/workflows/gui-ci.yml | 16 ++++++++ build/github.js | 50 +++++++++++++++++++++++++ build/package.json | 1 + build/release.js | 35 +++++++++-------- build/run.js | 10 ++++- build/workflow.js | 5 +++ config.json | 3 +- src/js/lib/client/tasks/signArchives.js | 3 +- src/js/lib/project-manager/src/build.ts | 12 +++--- 9 files changed, 110 insertions(+), 25 deletions(-) create mode 100644 build/github.js diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index 82de4360d8..d491d234ab 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -40,6 +40,8 @@ jobs: steps: - uses: actions/checkout@v1 - name: Setup environment + env: + GITHUB_TOKEN: ${{ github.token }} run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -56,6 +58,8 @@ jobs: node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" + echo "CI_BUILD_ENGINE_VERSION=${{ fromJson(steps.changelog.outputs.content).engineVersion }}" >> $GITHUB_ENV + echo $GITHUB_ENV shell: bash - name: Assert Version Unstable @@ -293,6 +297,8 @@ jobs: steps: - uses: actions/checkout@v1 - name: Setup environment + env: + GITHUB_TOKEN: ${{ github.token }} run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -309,6 +315,8 @@ jobs: node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" + echo "CI_BUILD_ENGINE_VERSION=${{ fromJson(steps.changelog.outputs.content).engineVersion }}" >> $GITHUB_ENV + echo $GITHUB_ENV shell: bash - name: Install Node @@ -454,6 +462,8 @@ jobs: with: path: artifacts - name: Setup environment + env: + GITHUB_TOKEN: ${{ github.token }} run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -470,6 +480,8 @@ jobs: node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" + echo "CI_BUILD_ENGINE_VERSION=${{ fromJson(steps.changelog.outputs.content).engineVersion }}" >> $GITHUB_ENV + echo $GITHUB_ENV shell: bash - id: checkCurrentReleaseTag @@ -523,6 +535,8 @@ jobs: with: path: artifacts - name: Setup environment + env: + GITHUB_TOKEN: ${{ github.token }} run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -539,6 +553,8 @@ jobs: node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" + echo "CI_BUILD_ENGINE_VERSION=${{ fromJson(steps.changelog.outputs.content).engineVersion }}" >> $GITHUB_ENV + echo $GITHUB_ENV shell: bash - shell: bash diff --git a/build/github.js b/build/github.js new file mode 100644 index 0000000000..c2d561c795 --- /dev/null +++ b/build/github.js @@ -0,0 +1,50 @@ +const { Octokit } = require("@octokit/core") + +const organization = 'enso-org' +const engineRepo = 'enso' +const token = process.env.GITHUB_TOKEN +const octokit = new Octokit({ auth: token }) + +function determineRepositoryName() { + const fallback = "ide" + const fallbackMessage = + "Could not determine the repository name, falling back to the default." + const fullName = process.env.GITHUB_REPOSITORY; + if (!fullName) { + console.log(fallbackMessage) + return fallback + } + + const prefix = organization + "/" + if (fullName.startsWith(prefix)) { + return fullName.substring(prefix.length) + } else { + console.log(fallbackMessage) + return fallback + } +} + +function isNightly(release) { + const nightlyInfix = "Nightly" + return release.name.indexOf(nightlyInfix) >= 0 && !release.draft +} + +async function fetchAllReleases(repo) { + const res = await octokit.request("GET /repos/{owner}/{repo}/releases", { + owner: organization, + repo: repo, + }) + return res.data +} + +async function fetchNightlies(repo) { + const releases = await fetchAllReleases(repo) + const nightlies = releases.filter(isNightly) + return nightlies +} + +async function fetchEngineNightlies() { + return await fetchNightlies(engineRepo) +} + +module.exports = { fetchEngineNightlies } diff --git a/build/package.json b/build/package.json index b1a62c5a52..53eb2fff05 100644 --- a/build/package.json +++ b/build/package.json @@ -8,6 +8,7 @@ "glob": "^7.1.6", "js-yaml": "4.0.0", "ncp": "^2.0.0", + "@octokit/core": "^3.5.0", "semver": "7.3.4", "unzipper": "^0.10.11", "yargs": "^15.3.0" diff --git a/build/release.js b/build/release.js index 08ba9fbc72..eca87ab085 100644 --- a/build/release.js +++ b/build/release.js @@ -1,10 +1,12 @@ /// Package release utilities. Especially, utilities to load `CHANGELOG.md`, extract the newest /// entry, and use it to generate package version and description. -const fss = require('fs') -const path = require('path') -const paths = require('./paths') -const semver = require('semver') +const fss = require('fs') +const path = require('path') +const paths = require('./paths') +const semver = require('semver') +const github = require('./github') +const appConfig = require('../config') @@ -24,7 +26,7 @@ const CHANGELOG_FILE = path.join(paths.root,CHANGELOG_FILE_NAME) class NextReleaseVersion { /// Version used for config files when building the package with "next version" in changelog. toString() { - if (this.isNightly()) { + if (isNightly()) { return this.prevVersion.toString() } else { return "0.0.0" @@ -34,11 +36,6 @@ class NextReleaseVersion { isPrerelease() { return true } - - isNightly() { - if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } - } - } class Version { @@ -71,10 +68,6 @@ class Version { if (this.tag) { return true } else { return false } } - isNightly() { - if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } - } - toString() { let suffix = '' if (this.tag) { @@ -83,7 +76,7 @@ class Version { suffix += `.${this.rcTag}.${this.rcTagVersion}` } } - if (this.isNightly()) { + if (isNightly()) { suffix += `-nightly-${this.year}-${this.month}-${this.day}` } return `${this.major}.${this.minor}.${this.patch}${suffix}` @@ -207,10 +200,20 @@ function currentVersion() { return changelog().currentVersion() } +function isNightly() { + if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } +} +function engineVersion() { + if (process.env.CI_BUILD_ENGINE_VERSION) { + return process.env.CI_BUILD_ENGINE_VERSION + } else { + return appConfig.engineVersion + } +} // =============== // === Exports === // =============== -module.exports = {Version,NextReleaseVersion,changelog,currentVersion} +module.exports = {Version,NextReleaseVersion,changelog,currentVersion,engineVersion} diff --git a/build/run.js b/build/run.js index 2270a6e10e..78f9d501be 100755 --- a/build/run.js +++ b/build/run.js @@ -284,7 +284,7 @@ commands.watch.common = async function(argv) { await cmd.with_cwd(paths.js.root, async () => { // Among other things, this will call the build script of the project-manager package. But // this is unnecessary because that script is already called by `build_project_manager` - // above. + // above. return commands.build.js(argv) }) @@ -335,11 +335,17 @@ commands.dist.js = async function() { /// of the product release. commands['ci-gen'] = command(`Generate CI build related files`) commands['ci-gen'].rust = async function(argv) { + let github = require('./github') + let nightlies = await github.fetchEngineNightlies() + console.log('nightlies', { nightlies }) + let engineVersion = nightlies[0].version + console.log('nightlies[0]', nightlies[0]) + let entry = release.changelog().newestEntry() let body = entry.body let version = entry.version.toString() let prerelease = entry.isPrerelease() - let obj = {version,body,prerelease}; + let obj = {version,body,prerelease,engineVersion}; let json = JSON.stringify(obj) fss.writeFileSync(path.join(paths.root,'CURRENT_RELEASE_CHANGELOG.json'),json) } diff --git a/build/workflow.js b/build/workflow.js index e64db30e04..475997bcbe 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -295,6 +295,9 @@ let getListOfChangedFiles = { let setupEnvironment = { name: 'Setup environment', + env: { + GITHUB_TOKEN: '${{ github.token }}' + }, run: ` if [[ \$\{\{ github.event_name \}\} == 'schedule' ]]; then @@ -312,6 +315,8 @@ let getCurrentReleaseChangelogInfo = { node ./run ci-gen --skip-version-validation content=\`cat CURRENT_RELEASE_CHANGELOG.json\` echo "::set-output name=content::$content" + echo "CI_BUILD_ENGINE_VERSION=\$\{\{ fromJson(steps.changelog.outputs.content).engineVersion \}\}" >> $GITHUB_ENV + echo $GITHUB_ENV `, shell: 'bash' } diff --git a/config.json b/config.json index 12a9d28d02..087042eea8 100644 --- a/config.json +++ b/config.json @@ -1,3 +1,4 @@ { - "minimumSupportedVersion": "2.0.0-alpha.6" + "minimumSupportedVersion": "2.0.0-alpha.6", + "engineVersion": "0.2.27" } diff --git a/src/js/lib/client/tasks/signArchives.js b/src/js/lib/client/tasks/signArchives.js index a56aca2ce5..44a48bb23e 100644 --- a/src/js/lib/client/tasks/signArchives.js +++ b/src/js/lib/client/tasks/signArchives.js @@ -16,13 +16,14 @@ const path = require('path') const child_process = require('child_process') const { dist } = require('../../../../../build/paths') +const { engineVersion } = require('../../../../../build/release') const contentRoot = path.join(dist.root, 'client', 'mac', 'Enso.app', 'Contents') const resRoot = path.join(contentRoot, 'Resources') // TODO: Refactor this once we have a better wau to get the used engine version. // See the tracking issue for more information https://github.com/enso-org/ide/issues/1359 -const ENGINE = '0.2.28' +const ENGINE = engineVersion() const ID = '"Developer ID Application: New Byte Order Sp. z o. o. (NM77WTZJFQ)"' // Placeholder name for temporary archives. const tmpArchive = 'temporary_archive.zip' diff --git a/src/js/lib/project-manager/src/build.ts b/src/js/lib/project-manager/src/build.ts index e866f251db..14806e4db9 100644 --- a/src/js/lib/project-manager/src/build.ts +++ b/src/js/lib/project-manager/src/build.ts @@ -13,6 +13,8 @@ import * as unzipper from 'unzipper' import * as url from 'url' // @ts-ignore import * as paths from './../../../../../build/paths' +// @ts-ignore +import { engineVersion } from './../../../../../build/release' import { IncomingMessage } from 'http' const fs = fss.promises @@ -132,14 +134,14 @@ async function download_project_manager(file_url: string, overwrite: boolean): P ) } else { await fs.mkdir(download_dir, { recursive: true }) - + const parsed = url.parse(file_url) const options = { host: parsed.host, port: 80, path: parsed.pathname, } - + const target_file = fss.createWriteStream(file_path) const progress_indicator = new DownloadProgressIndicator() await new Promise((resolve, reject) => @@ -172,10 +174,10 @@ async function main() { // Also it is usually a good idea to synchronize it with `ENGINE_VERSION_FOR_NEW_PROJECTS` in // src/rust/ide/src/controller/project.rs. See also https://github.com/enso-org/ide/issues/1359 const buildInfo: BuildInfo = { - version: '0.2.28', + version: engineVersion(), target: (await get_build_config()).target, } - + // The file at path `buildInfoFile` should always contain the build info of the project manager // that is currently installed in the dist directory. We read the file if it exists and compare // it with the version and target platform that we need. If they already agree then the right @@ -195,7 +197,7 @@ async function main() { } } if (buildInfo.version !== existing_build_info?.version || - buildInfo.target !== existing_build_info?.target) { + buildInfo.target !== existing_build_info?.target) { // We remove the build info file to avoid misinformation if the build is interrupted during // the call to `download_project_manager`. From a37a2b0243da10e8df526ce01c70da22c3093e6e Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 12:13:02 +0300 Subject: [PATCH 12/33] fix: env --- .github/workflows/gui-ci.yml | 16 ++++++++++++---- build/release.js | 2 +- build/run.js | 14 +++++++++----- build/workflow.js | 4 +++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index d491d234ab..cac8784f15 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -55,10 +55,12 @@ jobs: id: changelog run: |2- + touch .environment node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" - echo "CI_BUILD_ENGINE_VERSION=${{ fromJson(steps.changelog.outputs.content).engineVersion }}" >> $GITHUB_ENV + environment=`cat .environment` + echo $environment >> $GITHUB_ENV echo $GITHUB_ENV shell: bash @@ -312,10 +314,12 @@ jobs: id: changelog run: |2- + touch .environment node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" - echo "CI_BUILD_ENGINE_VERSION=${{ fromJson(steps.changelog.outputs.content).engineVersion }}" >> $GITHUB_ENV + environment=`cat .environment` + echo $environment >> $GITHUB_ENV echo $GITHUB_ENV shell: bash @@ -477,10 +481,12 @@ jobs: id: changelog run: |2- + touch .environment node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" - echo "CI_BUILD_ENGINE_VERSION=${{ fromJson(steps.changelog.outputs.content).engineVersion }}" >> $GITHUB_ENV + environment=`cat .environment` + echo $environment >> $GITHUB_ENV echo $GITHUB_ENV shell: bash @@ -550,10 +556,12 @@ jobs: id: changelog run: |2- + touch .environment node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" - echo "CI_BUILD_ENGINE_VERSION=${{ fromJson(steps.changelog.outputs.content).engineVersion }}" >> $GITHUB_ENV + environment=`cat .environment` + echo $environment >> $GITHUB_ENV echo $GITHUB_ENV shell: bash diff --git a/build/release.js b/build/release.js index eca87ab085..ed57048e4e 100644 --- a/build/release.js +++ b/build/release.js @@ -216,4 +216,4 @@ function engineVersion() { // === Exports === // =============== -module.exports = {Version,NextReleaseVersion,changelog,currentVersion,engineVersion} +module.exports = {Version,NextReleaseVersion,changelog,currentVersion,isNightly,engineVersion} diff --git a/build/run.js b/build/run.js index 78f9d501be..b89a75704d 100755 --- a/build/run.js +++ b/build/run.js @@ -335,11 +335,15 @@ commands.dist.js = async function() { /// of the product release. commands['ci-gen'] = command(`Generate CI build related files`) commands['ci-gen'].rust = async function(argv) { - let github = require('./github') - let nightlies = await github.fetchEngineNightlies() - console.log('nightlies', { nightlies }) - let engineVersion = nightlies[0].version - console.log('nightlies[0]', nightlies[0]) + if (release.isNightly()) { + let github = require('./github') + let nightlies = await github.fetchEngineNightlies() + console.log('nightlies', { nightlies }) + let engineVersion = nightlies[0].version + console.log('nightlies[0]', nightlies[0]) + let env = `CI_BUILD_ENGINE_VERSION=${engineVersion}` + fss.writeFileSync(path.join(paths.root, '.environment'), env) + } let entry = release.changelog().newestEntry() let body = entry.body diff --git a/build/workflow.js b/build/workflow.js index 475997bcbe..37bc49da1c 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -312,10 +312,12 @@ let getCurrentReleaseChangelogInfo = { name: 'Read changelog info', id: 'changelog', run: ` + touch .environment node ./run ci-gen --skip-version-validation content=\`cat CURRENT_RELEASE_CHANGELOG.json\` echo "::set-output name=content::$content" - echo "CI_BUILD_ENGINE_VERSION=\$\{\{ fromJson(steps.changelog.outputs.content).engineVersion \}\}" >> $GITHUB_ENV + environment=\`cat .environment\` + echo $environment >> $GITHUB_ENV echo $GITHUB_ENV `, shell: 'bash' From b518a8beeac42b6fd88953aeef14b1df3f0a32e4 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 12:16:46 +0300 Subject: [PATCH 13/33] fix: token --- .github/workflows/gui-ci.yml | 16 ++++++++-------- build/workflow.js | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index cac8784f15..b92b7e8198 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -40,8 +40,6 @@ jobs: steps: - uses: actions/checkout@v1 - name: Setup environment - env: - GITHUB_TOKEN: ${{ github.token }} run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -52,6 +50,8 @@ jobs: shell: bash - name: Read changelog info + env: + GITHUB_TOKEN: ${{ github.token }} id: changelog run: |2- @@ -299,8 +299,6 @@ jobs: steps: - uses: actions/checkout@v1 - name: Setup environment - env: - GITHUB_TOKEN: ${{ github.token }} run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -311,6 +309,8 @@ jobs: shell: bash - name: Read changelog info + env: + GITHUB_TOKEN: ${{ github.token }} id: changelog run: |2- @@ -466,8 +466,6 @@ jobs: with: path: artifacts - name: Setup environment - env: - GITHUB_TOKEN: ${{ github.token }} run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -478,6 +476,8 @@ jobs: shell: bash - name: Read changelog info + env: + GITHUB_TOKEN: ${{ github.token }} id: changelog run: |2- @@ -541,8 +541,6 @@ jobs: with: path: artifacts - name: Setup environment - env: - GITHUB_TOKEN: ${{ github.token }} run: |2- if [[ ${{ github.event_name }} == 'schedule' ]]; @@ -553,6 +551,8 @@ jobs: shell: bash - name: Read changelog info + env: + GITHUB_TOKEN: ${{ github.token }} id: changelog run: |2- diff --git a/build/workflow.js b/build/workflow.js index 37bc49da1c..cfd58529a1 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -295,9 +295,6 @@ let getListOfChangedFiles = { let setupEnvironment = { name: 'Setup environment', - env: { - GITHUB_TOKEN: '${{ github.token }}' - }, run: ` if [[ \$\{\{ github.event_name \}\} == 'schedule' ]]; then @@ -310,6 +307,9 @@ let setupEnvironment = { let getCurrentReleaseChangelogInfo = { name: 'Read changelog info', + env: { + GITHUB_TOKEN: '${{ github.token }}', + }, id: 'changelog', run: ` touch .environment From b0c9145f30dca3e08966066021a1aada23451f8a Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 12:23:07 +0300 Subject: [PATCH 14/33] fix: json --- build/run.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/run.js b/build/run.js index b89a75704d..80b4d967a4 100755 --- a/build/run.js +++ b/build/run.js @@ -338,9 +338,12 @@ commands['ci-gen'].rust = async function(argv) { if (release.isNightly()) { let github = require('./github') let nightlies = await github.fetchEngineNightlies() - console.log('nightlies', { nightlies }) - let engineVersion = nightlies[0].version + let engineVersion = nightlies[0].name console.log('nightlies[0]', nightlies[0]) + let nightlyPrefix = "Enso Nightly " + if (engineVersion.startsWith(nightlyPrefix)) { + engineVersion = engineVersion.substring(nightlyPrefix.length) + } let env = `CI_BUILD_ENGINE_VERSION=${engineVersion}` fss.writeFileSync(path.join(paths.root, '.environment'), env) } From 4556152be81fc960abacdf4d22587405d58c36f5 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 12:25:40 +0300 Subject: [PATCH 15/33] fix: js --- build/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/run.js b/build/run.js index 80b4d967a4..f574dcc5ee 100755 --- a/build/run.js +++ b/build/run.js @@ -352,7 +352,7 @@ commands['ci-gen'].rust = async function(argv) { let body = entry.body let version = entry.version.toString() let prerelease = entry.isPrerelease() - let obj = {version,body,prerelease,engineVersion}; + let obj = {version,body,prerelease} let json = JSON.stringify(obj) fss.writeFileSync(path.join(paths.root,'CURRENT_RELEASE_CHANGELOG.json'),json) } From 5db7ea3f39352347535283ea933583e977f6e847 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 12:49:49 +0300 Subject: [PATCH 16/33] misc: cleanup --- .github/workflows/gui-ci.yml | 12 ++++-------- build/run.js | 6 +++--- build/workflow.js | 3 +-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index b92b7e8198..0aaa5d0daa 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -55,13 +55,12 @@ jobs: id: changelog run: |2- - touch .environment node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" environment=`cat .environment` echo $environment >> $GITHUB_ENV - echo $GITHUB_ENV + cat $GITHUB_ENV shell: bash - name: Assert Version Unstable @@ -314,13 +313,12 @@ jobs: id: changelog run: |2- - touch .environment node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" environment=`cat .environment` echo $environment >> $GITHUB_ENV - echo $GITHUB_ENV + cat $GITHUB_ENV shell: bash - name: Install Node @@ -481,13 +479,12 @@ jobs: id: changelog run: |2- - touch .environment node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" environment=`cat .environment` echo $environment >> $GITHUB_ENV - echo $GITHUB_ENV + cat $GITHUB_ENV shell: bash - id: checkCurrentReleaseTag @@ -556,13 +553,12 @@ jobs: id: changelog run: |2- - touch .environment node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" environment=`cat .environment` echo $environment >> $GITHUB_ENV - echo $GITHUB_ENV + cat $GITHUB_ENV shell: bash - shell: bash diff --git a/build/run.js b/build/run.js index f574dcc5ee..d6fde62df3 100755 --- a/build/run.js +++ b/build/run.js @@ -335,18 +335,18 @@ commands.dist.js = async function() { /// of the product release. commands['ci-gen'] = command(`Generate CI build related files`) commands['ci-gen'].rust = async function(argv) { + let env = '' if (release.isNightly()) { let github = require('./github') let nightlies = await github.fetchEngineNightlies() let engineVersion = nightlies[0].name - console.log('nightlies[0]', nightlies[0]) let nightlyPrefix = "Enso Nightly " if (engineVersion.startsWith(nightlyPrefix)) { engineVersion = engineVersion.substring(nightlyPrefix.length) } - let env = `CI_BUILD_ENGINE_VERSION=${engineVersion}` - fss.writeFileSync(path.join(paths.root, '.environment'), env) + env += `CI_BUILD_ENGINE_VERSION=${engineVersion}` } + fss.writeFileSync(path.join(paths.root, '.environment'), env) let entry = release.changelog().newestEntry() let body = entry.body diff --git a/build/workflow.js b/build/workflow.js index cfd58529a1..b310d83871 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -312,13 +312,12 @@ let getCurrentReleaseChangelogInfo = { }, id: 'changelog', run: ` - touch .environment node ./run ci-gen --skip-version-validation content=\`cat CURRENT_RELEASE_CHANGELOG.json\` echo "::set-output name=content::$content" environment=\`cat .environment\` echo $environment >> $GITHUB_ENV - echo $GITHUB_ENV + cat $GITHUB_ENV `, shell: 'bash' } From 24bdb38dbd9b6240312ab013aed8aabe01f2240d Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 14:34:08 +0300 Subject: [PATCH 17/33] fix: nightly date --- build/release.js | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/build/release.js b/build/release.js index ed57048e4e..afe0c93c80 100644 --- a/build/release.js +++ b/build/release.js @@ -27,7 +27,7 @@ class NextReleaseVersion { /// Version used for config files when building the package with "next version" in changelog. toString() { if (isNightly()) { - return this.prevVersion.toString() + return nightlyVersion() } else { return "0.0.0" } @@ -39,7 +39,7 @@ class NextReleaseVersion { } class Version { - constructor(major,minor,patch,tag,tagVersion,rcTag,rcTagVersion,year,month,day) { + constructor(major,minor,patch,tag,tagVersion,rcTag,rcTagVersion) { this.major = major this.minor = minor this.patch = patch @@ -47,9 +47,6 @@ class Version { this.tagVersion = parseInt(tagVersion) this.rcTag = rcTag this.rcTagVersion = rcTagVersion - this.year = year - this.month = month - this.day = day } lt(that) { @@ -69,6 +66,9 @@ class Version { } toString() { + if (isNightly()) { + return nightlyVersion() + } let suffix = '' if (this.tag) { suffix = `-${this.tag}.${this.tagVersion}` @@ -76,9 +76,6 @@ class Version { suffix += `.${this.rcTag}.${this.rcTagVersion}` } } - if (isNightly()) { - suffix += `-nightly-${this.year}-${this.month}-${this.day}` - } return `${this.major}.${this.minor}.${this.patch}${suffix}` } } @@ -148,7 +145,6 @@ function changelogSections() { function changelogEntries() { let sections = changelogSections() - let nextRelease = new NextReleaseVersion let entries = [] let firstSection = true for (let section of sections) { @@ -156,7 +152,7 @@ function changelogEntries() { let header = section.substring(0,splitPoint) let body = section.substring(splitPoint).trim() if (firstSection && header.startsWith(' Next Release')) { - let version = nextRelease + let version = new NextReleaseVersion entries.push(new ChangelogEntry(version,body)) } else { let headerReg = /^ Enso (?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)(-(?alpha|beta|rc)\.(?[0-9]+))?(.(?rc)\.(?[0-9]+))? \((?[0-9][0-9][0-9][0-9])-(?[0-9][0-9])-(?[0-9][0-9])\)/ @@ -165,10 +161,7 @@ function changelogEntries() { throw `Improper changelog entry header: '${header}'. See the 'CHANGELOG_TEMPLATE.md' for details.` } let grps = match.groups - let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion,grps.year,grps.month,grps.day) - if (nextRelease.prevVersion === undefined) { - nextRelease.prevVersion = version - } + let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion) entries.push(new ChangelogEntry(version,body)) } firstSection = false @@ -200,10 +193,21 @@ function currentVersion() { return changelog().currentVersion() } +// =============== +// === Nightly === +// =============== + function isNightly() { if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } } +/// Return version in format `nightly-YYYY-MM-DD`. +function nightlyVersion() { + let date = new Date() + let isoDate = date.toISOString().split('T')[0] + return `nightly-${isoDate}` +} + function engineVersion() { if (process.env.CI_BUILD_ENGINE_VERSION) { return process.env.CI_BUILD_ENGINE_VERSION From 4526ce0f25609a78a9d8ad5bdf31eb535a55da77 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 15:51:22 +0300 Subject: [PATCH 18/33] Revert "fix: nightly date" This reverts commit 3ab4b22c770410d5573eb4c0a56b4e55d65c9785. --- build/release.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/build/release.js b/build/release.js index afe0c93c80..ed57048e4e 100644 --- a/build/release.js +++ b/build/release.js @@ -27,7 +27,7 @@ class NextReleaseVersion { /// Version used for config files when building the package with "next version" in changelog. toString() { if (isNightly()) { - return nightlyVersion() + return this.prevVersion.toString() } else { return "0.0.0" } @@ -39,7 +39,7 @@ class NextReleaseVersion { } class Version { - constructor(major,minor,patch,tag,tagVersion,rcTag,rcTagVersion) { + constructor(major,minor,patch,tag,tagVersion,rcTag,rcTagVersion,year,month,day) { this.major = major this.minor = minor this.patch = patch @@ -47,6 +47,9 @@ class Version { this.tagVersion = parseInt(tagVersion) this.rcTag = rcTag this.rcTagVersion = rcTagVersion + this.year = year + this.month = month + this.day = day } lt(that) { @@ -66,9 +69,6 @@ class Version { } toString() { - if (isNightly()) { - return nightlyVersion() - } let suffix = '' if (this.tag) { suffix = `-${this.tag}.${this.tagVersion}` @@ -76,6 +76,9 @@ class Version { suffix += `.${this.rcTag}.${this.rcTagVersion}` } } + if (isNightly()) { + suffix += `-nightly-${this.year}-${this.month}-${this.day}` + } return `${this.major}.${this.minor}.${this.patch}${suffix}` } } @@ -145,6 +148,7 @@ function changelogSections() { function changelogEntries() { let sections = changelogSections() + let nextRelease = new NextReleaseVersion let entries = [] let firstSection = true for (let section of sections) { @@ -152,7 +156,7 @@ function changelogEntries() { let header = section.substring(0,splitPoint) let body = section.substring(splitPoint).trim() if (firstSection && header.startsWith(' Next Release')) { - let version = new NextReleaseVersion + let version = nextRelease entries.push(new ChangelogEntry(version,body)) } else { let headerReg = /^ Enso (?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)(-(?alpha|beta|rc)\.(?[0-9]+))?(.(?rc)\.(?[0-9]+))? \((?[0-9][0-9][0-9][0-9])-(?[0-9][0-9])-(?[0-9][0-9])\)/ @@ -161,7 +165,10 @@ function changelogEntries() { throw `Improper changelog entry header: '${header}'. See the 'CHANGELOG_TEMPLATE.md' for details.` } let grps = match.groups - let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion) + let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion,grps.year,grps.month,grps.day) + if (nextRelease.prevVersion === undefined) { + nextRelease.prevVersion = version + } entries.push(new ChangelogEntry(version,body)) } firstSection = false @@ -193,21 +200,10 @@ function currentVersion() { return changelog().currentVersion() } -// =============== -// === Nightly === -// =============== - function isNightly() { if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } } -/// Return version in format `nightly-YYYY-MM-DD`. -function nightlyVersion() { - let date = new Date() - let isoDate = date.toISOString().split('T')[0] - return `nightly-${isoDate}` -} - function engineVersion() { if (process.env.CI_BUILD_ENGINE_VERSION) { return process.env.CI_BUILD_ENGINE_VERSION From 40d1f9545f6c5ca7a0e7f8ac95f7bf52367daca8 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 16:04:14 +0300 Subject: [PATCH 19/33] misc: nightly date --- build/release.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/build/release.js b/build/release.js index ed57048e4e..ee840a4bf1 100644 --- a/build/release.js +++ b/build/release.js @@ -39,7 +39,7 @@ class NextReleaseVersion { } class Version { - constructor(major,minor,patch,tag,tagVersion,rcTag,rcTagVersion,year,month,day) { + constructor(major,minor,patch,tag,tagVersion,rcTag,rcTagVersion) { this.major = major this.minor = minor this.patch = patch @@ -47,9 +47,6 @@ class Version { this.tagVersion = parseInt(tagVersion) this.rcTag = rcTag this.rcTagVersion = rcTagVersion - this.year = year - this.month = month - this.day = day } lt(that) { @@ -69,6 +66,10 @@ class Version { } toString() { + let version = `${this.major}.${this.minor}.${this.patch}` + if (isNightly()) { + return `${version}-nightly.${isoDate()}` + } let suffix = '' if (this.tag) { suffix = `-${this.tag}.${this.tagVersion}` @@ -76,10 +77,7 @@ class Version { suffix += `.${this.rcTag}.${this.rcTagVersion}` } } - if (isNightly()) { - suffix += `-nightly-${this.year}-${this.month}-${this.day}` - } - return `${this.major}.${this.minor}.${this.patch}${suffix}` + return `${version}${suffix}` } } @@ -165,7 +163,7 @@ function changelogEntries() { throw `Improper changelog entry header: '${header}'. See the 'CHANGELOG_TEMPLATE.md' for details.` } let grps = match.groups - let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion,grps.year,grps.month,grps.day) + let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion) if (nextRelease.prevVersion === undefined) { nextRelease.prevVersion = version } @@ -204,6 +202,11 @@ function isNightly() { if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } } +function isoDate() { + let date = new Date() + return date.toISOString().split('T')[0] +} + function engineVersion() { if (process.env.CI_BUILD_ENGINE_VERSION) { return process.env.CI_BUILD_ENGINE_VERSION From c68f2985463f4f07a834ac26720162e152a81e33 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Fri, 3 Sep 2021 16:15:51 +0300 Subject: [PATCH 20/33] feat: delete older nightlies --- .github/workflows/gui-ci.yml | 10 ++++++++++ build/workflow.js | 17 ++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index 0aaa5d0daa..c18503a4b2 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -4,6 +4,8 @@ # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! name: GUI CI +env: + NIGHTLIES_TO_KEEP: 20 'on': push: branches: @@ -515,6 +517,14 @@ jobs: body: ${{fromJson(steps.changelog.outputs.content).body}} prerelease: ${{fromJson(steps.changelog.outputs.content).prerelease}} draft: true + - uses: dev-drprasad/delete-older-releases@v0.2.0 + name: Remove Old Releases + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + keep_latest: ${{ env.NIGHTLIES_TO_KEEP }} + delete_tag_pattern: nightly + delete_tags: true if: >- github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable' || true diff --git a/build/workflow.js b/build/workflow.js index b310d83871..69f8466462 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -360,7 +360,18 @@ let uploadGitHubRelease = [ } ] - +let deleteOlderNightlies = { + uses: 'dev-drprasad/delete-older-releases@v0.2.0', + name: 'Remove Old Releases', + env: { + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}', + }, + with: { + keep_latest: '${{ env.NIGHTLIES_TO_KEEP }}', + delete_tag_pattern: 'nightly', + delete_tags: true, + }, +} // =================== // === CDN Release === @@ -467,6 +478,9 @@ let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_B let workflow = { name : "GUI CI", + env: { + NIGHTLIES_TO_KEEP: 20, + }, on: { push: { branches: ['develop','unstable','stable','wip/db/nightly-release'], @@ -544,6 +558,7 @@ let workflow = { // running. assertReleaseDoNotExists, uploadGitHubRelease, + deleteOlderNightlies, ],{ if:releaseCondition, needs:['version_assertions','lint','test','build'] }), From 7572cdda811504cff9a1898f9651f46179940251 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 11:38:32 +0300 Subject: [PATCH 21/33] misc: bump engine --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 087042eea8..2435bd2312 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,4 @@ { "minimumSupportedVersion": "2.0.0-alpha.6", - "engineVersion": "0.2.27" + "engineVersion": "0.2.28" } From 7b19de19e7219a5f9acf0e0b0bf70aed31d7beef Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 12:39:05 +0300 Subject: [PATCH 22/33] refactor: ci build --- .github/workflows/gui-ci.yml | 92 +++++++++++++++--------------------- build/paths.js | 2 + build/release.js | 53 ++++++++------------- build/run.js | 41 +++++++++++----- build/workflow.js | 63 ++++++++++++------------ 5 files changed, 122 insertions(+), 129 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index c18503a4b2..c6c0bc4c3c 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -41,28 +41,24 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v1 - - name: Setup environment + - name: Setup nightly + env: + GITHUB_TOKEN: ${{ github.token }} run: |2- - if [[ ${{ github.event_name }} == 'schedule' ]]; - then - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV - fi - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + node ./run nightly-gen --skip-version-validation + cat config.json + head CHANGELOG.md + if: github.event.name == 'schedule' || true shell: bash - name: Read changelog info - env: - GITHUB_TOKEN: ${{ github.token }} id: changelog run: |2- node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" - environment=`cat .environment` - echo $environment >> $GITHUB_ENV - cat $GITHUB_ENV shell: bash - name: Assert Version Unstable @@ -82,8 +78,8 @@ jobs: if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi if: >- - env.CI_BUILD_NIGHTLY == 'true' || github.base_ref == 'unstable' || - github.base_ref == 'stable' + github.event.name == 'schedule' || true || github.base_ref == + 'unstable' || github.base_ref == 'stable' - name: Get list of changed files id: changed_files run: |2- @@ -299,28 +295,24 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v1 - - name: Setup environment + - name: Setup nightly + env: + GITHUB_TOKEN: ${{ github.token }} run: |2- - if [[ ${{ github.event_name }} == 'schedule' ]]; - then - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV - fi - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + node ./run nightly-gen --skip-version-validation + cat config.json + head CHANGELOG.md + if: github.event.name == 'schedule' || true shell: bash - name: Read changelog info - env: - GITHUB_TOKEN: ${{ github.token }} id: changelog run: |2- node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" - environment=`cat .environment` - echo $environment >> $GITHUB_ENV - cat $GITHUB_ENV shell: bash - name: Install Node @@ -449,8 +441,8 @@ jobs: contains(github.event.pull_request.body,'[ci build]') || contains(github.event.head_commit.message,'[ci build]') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref - == 'stable' || (github.event_name == 'schedule' || github.ref == - 'refs/heads/unstable' || github.ref == 'refs/heads/stable' || true) + == 'stable' || (github.event.name == 'schedule' || true || github.ref == + 'refs/heads/unstable' || github.ref == 'refs/heads/stable') release_to_github: name: GitHub Release runs-on: ${{ matrix.os }} @@ -465,28 +457,24 @@ jobs: uses: actions/download-artifact@v2 with: path: artifacts - - name: Setup environment + - name: Setup nightly + env: + GITHUB_TOKEN: ${{ github.token }} run: |2- - if [[ ${{ github.event_name }} == 'schedule' ]]; - then - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV - fi - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + node ./run nightly-gen --skip-version-validation + cat config.json + head CHANGELOG.md + if: github.event.name == 'schedule' || true shell: bash - name: Read changelog info - env: - GITHUB_TOKEN: ${{ github.token }} id: changelog run: |2- node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" - environment=`cat .environment` - echo $environment >> $GITHUB_ENV - cat $GITHUB_ENV shell: bash - id: checkCurrentReleaseTag @@ -500,8 +488,8 @@ jobs: if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi if: >- - env.CI_BUILD_NIGHTLY == 'true' || github.base_ref == 'unstable' || - github.base_ref == 'stable' + github.event.name == 'schedule' || true || github.base_ref == + 'unstable' || github.base_ref == 'stable' - name: Install Prettier run: npm install --save-dev --save-exact prettier - name: Pretty print changelog. @@ -526,8 +514,8 @@ jobs: delete_tag_pattern: nightly delete_tags: true if: >- - github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || - github.ref == 'refs/heads/stable' || true + github.event.name == 'schedule' || true || github.ref == + 'refs/heads/unstable' || github.ref == 'refs/heads/stable' needs: - version_assertions - lint @@ -547,28 +535,24 @@ jobs: uses: actions/download-artifact@v2 with: path: artifacts - - name: Setup environment + - name: Setup nightly + env: + GITHUB_TOKEN: ${{ github.token }} run: |2- - if [[ ${{ github.event_name }} == 'schedule' ]]; - then - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV - fi - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + node ./run nightly-gen --skip-version-validation + cat config.json + head CHANGELOG.md + if: github.event.name == 'schedule' || true shell: bash - name: Read changelog info - env: - GITHUB_TOKEN: ${{ github.token }} id: changelog run: |2- node ./run ci-gen --skip-version-validation content=`cat CURRENT_RELEASE_CHANGELOG.json` echo "::set-output name=content::$content" - environment=`cat .environment` - echo $environment >> $GITHUB_ENV - cat $GITHUB_ENV shell: bash - shell: bash @@ -607,8 +591,8 @@ jobs: s3://ensocdn/ide/${{fromJson(steps.changelog.outputs.content).version}}/wasm_imports.js.gz --profile s3-upload --acl public-read --content-encoding gzip if: >- - github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || - github.ref == 'refs/heads/stable' || true + github.event.name == 'schedule' || true || github.ref == + 'refs/heads/unstable' || github.ref == 'refs/heads/stable' needs: - version_assertions - lint diff --git a/build/paths.js b/build/paths.js index 7d1fba9ba3..48744fc32e 100644 --- a/build/paths.js +++ b/build/paths.js @@ -11,6 +11,8 @@ let paths = {} paths.root = path.dirname(__dirname) +paths.changelog = path.join(paths.root,'CHANGELOG.md') + paths.script = {} paths.script.main = path.join(paths.root,'run') paths.script.root = path.join(paths.root,'build') diff --git a/build/release.js b/build/release.js index ee840a4bf1..cf2d245aa7 100644 --- a/build/release.js +++ b/build/release.js @@ -1,12 +1,11 @@ /// Package release utilities. Especially, utilities to load `CHANGELOG.md`, extract the newest /// entry, and use it to generate package version and description. -const fss = require('fs') -const path = require('path') -const paths = require('./paths') -const semver = require('semver') -const github = require('./github') -const appConfig = require('../config') +const fss = require('fs') +const path = require('path') +const paths = require('./paths') +const semver = require('semver') +const config = require('../config') @@ -26,11 +25,7 @@ const CHANGELOG_FILE = path.join(paths.root,CHANGELOG_FILE_NAME) class NextReleaseVersion { /// Version used for config files when building the package with "next version" in changelog. toString() { - if (isNightly()) { - return this.prevVersion.toString() - } else { - return "0.0.0" - } + return "0.0.0" } isPrerelease() { @@ -66,10 +61,6 @@ class Version { } toString() { - let version = `${this.major}.${this.minor}.${this.patch}` - if (isNightly()) { - return `${version}-nightly.${isoDate()}` - } let suffix = '' if (this.tag) { suffix = `-${this.tag}.${this.tagVersion}` @@ -77,7 +68,7 @@ class Version { suffix += `.${this.rcTag}.${this.rcTagVersion}` } } - return `${version}${suffix}` + return `${this.major}.${this.minor}.${this.patch}${suffix}` } } @@ -146,7 +137,6 @@ function changelogSections() { function changelogEntries() { let sections = changelogSections() - let nextRelease = new NextReleaseVersion let entries = [] let firstSection = true for (let section of sections) { @@ -154,7 +144,7 @@ function changelogEntries() { let header = section.substring(0,splitPoint) let body = section.substring(splitPoint).trim() if (firstSection && header.startsWith(' Next Release')) { - let version = nextRelease + let version = new NextReleaseVersion entries.push(new ChangelogEntry(version,body)) } else { let headerReg = /^ Enso (?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)(-(?alpha|beta|rc)\.(?[0-9]+))?(.(?rc)\.(?[0-9]+))? \((?[0-9][0-9][0-9][0-9])-(?[0-9][0-9])-(?[0-9][0-9])\)/ @@ -164,9 +154,6 @@ function changelogEntries() { } let grps = match.groups let version = new Version(grps.major,grps.minor,grps.patch,grps.tag,grps.tagVersion,grps.rcTag,grps.rcTagVersion) - if (nextRelease.prevVersion === undefined) { - nextRelease.prevVersion = version - } entries.push(new ChangelogEntry(version,body)) } firstSection = false @@ -198,8 +185,18 @@ function currentVersion() { return changelog().currentVersion() } -function isNightly() { - if (process.env.CI_BUILD_NIGHTLY) { return true } else { return false } +function engineVersion() { + return config.engineVersion +} + +function nightlyVersion() { + let changelog = changelog() + let version = changelog.entries[0].version + if (version instanceof NextReleaseVersion) { + version = changelog.entries[1].version + } + + return `${version.major}.${version.minor}.${version.patch}-nightly.${isoDate()}` } function isoDate() { @@ -207,16 +204,8 @@ function isoDate() { return date.toISOString().split('T')[0] } -function engineVersion() { - if (process.env.CI_BUILD_ENGINE_VERSION) { - return process.env.CI_BUILD_ENGINE_VERSION - } else { - return appConfig.engineVersion - } -} - // =============== // === Exports === // =============== -module.exports = {Version,NextReleaseVersion,changelog,currentVersion,isNightly,engineVersion} +module.exports = {Version,NextReleaseVersion,changelog,currentVersion,engineVersion,nightlyVersion,isoDate} diff --git a/build/run.js b/build/run.js index d6fde62df3..ce1ef07a16 100755 --- a/build/run.js +++ b/build/run.js @@ -328,6 +328,34 @@ commands.dist.js = async function() { } +// === Nightly Gen === +commands['nightly-gen'] = command(`Generate Nightly CI build related files`) +commands['nightly-gen'].rust = async function(argv) { + let github = require('./github') + let nightlies = await github.fetchEngineNightlies() + let engineVersion = nightlies[0].name + let nightlyPrefix = "Enso Nightly " + if (engineVersion.startsWith(nightlyPrefix)) { + engineVersion = engineVersion.substring(nightlyPrefix.length) + } + + let isoDate = release.isoDate() + let nightlyVersion = release.nightlyVersion() + + let appConfig = require('../config') + appConfig.engineVersion = engineVersion + let appConfigPath = path.join(paths.root, 'config.json') + + console.log(`set engine version: ${engineVersion}`) + console.log(`set IDE nightly version: ${nightlyVersion}`) + + // Update config.json + fss.writeFileSync(path.join(paths.root, 'config.json'), JSON.stringify(appConfig)) + // Update changelog + await cmd.run('sed', ['-i', `1s/.*/# Enso ${nightlyVersion} (${isoDate})`, paths.changelog]) + +} + // === CI Gen === /// The command is used by CI to generate the file `CURRENT_RELEASE_CHANGELOG.json`, which contains @@ -335,19 +363,6 @@ commands.dist.js = async function() { /// of the product release. commands['ci-gen'] = command(`Generate CI build related files`) commands['ci-gen'].rust = async function(argv) { - let env = '' - if (release.isNightly()) { - let github = require('./github') - let nightlies = await github.fetchEngineNightlies() - let engineVersion = nightlies[0].name - let nightlyPrefix = "Enso Nightly " - if (engineVersion.startsWith(nightlyPrefix)) { - engineVersion = engineVersion.substring(nightlyPrefix.length) - } - env += `CI_BUILD_ENGINE_VERSION=${engineVersion}` - } - fss.writeFileSync(path.join(paths.root, '.environment'), env) - let entry = release.changelog().newestEntry() let body = entry.body let version = entry.version.toString() diff --git a/build/workflow.js b/build/workflow.js index 69f8466462..c76bc2eb97 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -21,6 +21,24 @@ const FLAG_FORCE_CI_BUILD = '[ci build]' +// ================== +// === Conditions === +// ================== + +let nightlyReleaseCondition = `github.event.name == 'schedule' || true` +/// Make a release only if it was a push to 'unstable' or 'stable'. Even if it was a pull request +/// FROM these branches, the `github.ref` will be different. +let releaseCondition = `${nightlyReleaseCondition} || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'` + +/// Make a full build if one of the following conditions is true: +/// 1. There was a `FLAG_FORCE_CI_BUILD` flag set in the commit message (see its docs for more info). +/// 2. It was a pull request to the 'unstable', or the 'stable' branch. +/// 3. It was a commit to the 'develop' branch. +/// Otherwise, perform a simplified (faster) build only. +let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_BUILD}') || contains(github.event.head_commit.message,'${FLAG_FORCE_CI_BUILD}') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (${releaseCondition})` + + + // ============= // === Utils === // ============= @@ -293,31 +311,27 @@ let getListOfChangedFiles = { // === Changelog === // ================= -let setupEnvironment = { - name: 'Setup environment', +let setupNightly = { + name: 'Setup nightly', + env: { + GITHUB_TOKEN: '${{ github.token }}', + }, run: ` - if [[ \$\{\{ github.event_name \}\} == 'schedule' ]]; - then - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV - fi - echo "CI_BUILD_NIGHTLY=true" >> $GITHUB_ENV + node ./run nightly-gen --skip-version-validation + cat config.json + head CHANGELOG.md `, - shell: 'bash' + if: `${nightlyReleaseCondition}`, + shell: 'bash', } let getCurrentReleaseChangelogInfo = { name: 'Read changelog info', - env: { - GITHUB_TOKEN: '${{ github.token }}', - }, id: 'changelog', run: ` node ./run ci-gen --skip-version-validation content=\`cat CURRENT_RELEASE_CHANGELOG.json\` echo "::set-output name=content::$content" - environment=\`cat .environment\` - echo $environment >> $GITHUB_ENV - cat $GITHUB_ENV `, shell: 'bash' } @@ -442,7 +456,7 @@ let assertReleaseDoNotExists = [ { name: 'Fail if release already exists', run: 'if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi', - if: `env.CI_BUILD_NIGHTLY == 'true' || github.base_ref == 'unstable' || github.base_ref == 'stable'` + if: `${nightlyReleaseCondition} || github.base_ref == 'unstable' || github.base_ref == 'stable'` } ] @@ -465,17 +479,6 @@ let assertions = list( // === Workflow === // =============== -/// Make a release only if it was a push to 'unstable' or 'stable'. Even if it was a pull request -/// FROM these branches, the `github.ref` will be different. -let releaseCondition = `github.event_name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable' || true` - -/// Make a full build if one of the following conditions is true: -/// 1. There was a `FLAG_FORCE_CI_BUILD` flag set in the commit message (see its docs for more info). -/// 2. It was a pull request to the 'unstable', or the 'stable' branch. -/// 3. It was a commit to the 'develop' branch. -/// Otherwise, perform a simplified (faster) build only. -let buildCondition = `contains(github.event.pull_request.body,'${FLAG_FORCE_CI_BUILD}') || contains(github.event.head_commit.message,'${FLAG_FORCE_CI_BUILD}') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref == 'stable' || (${releaseCondition})` - let workflow = { name : "GUI CI", env: { @@ -497,7 +500,7 @@ let workflow = { dumpGitHubContext ]), version_assertions: job_on_macos("Assertions", [ - setupEnvironment, + setupNightly, getCurrentReleaseChangelogInfo, assertions ]), @@ -533,7 +536,7 @@ let workflow = { buildOnMacOS, ]), build: job_on_all_platforms("Build", [ - setupEnvironment, + setupNightly, getCurrentReleaseChangelogInfo, installNode, installTypeScript, @@ -551,7 +554,7 @@ let workflow = { ],{if:buildCondition}), release_to_github: job_on_macos("GitHub Release", [ downloadArtifacts, - setupEnvironment, + setupNightly, getCurrentReleaseChangelogInfo, // This assertion is checked earlier, but we should double-check it in case several // CI jobs wil be run on this branch and a release was created when this workflow was @@ -564,7 +567,7 @@ let workflow = { }), release_to_cdn: job_on_ubuntu_18_04("CDN Release", [ downloadArtifacts, - setupEnvironment, + setupNightly, getCurrentReleaseChangelogInfo, prepareAwsSessionCDN, uploadToCDN('index.js.gz','style.css','ide.wasm','wasm_imports.js.gz'), From 476927122834f0658953bf767b5569eee23c967d Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 12:44:32 +0300 Subject: [PATCH 23/33] misc: fix js --- build/paths.js | 1 + build/release.js | 2 +- build/run.js | 4 +--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/build/paths.js b/build/paths.js index 48744fc32e..290b168a1f 100644 --- a/build/paths.js +++ b/build/paths.js @@ -12,6 +12,7 @@ let paths = {} paths.root = path.dirname(__dirname) paths.changelog = path.join(paths.root,'CHANGELOG.md') +paths.configJson = path.join(paths.root,'config.json') paths.script = {} paths.script.main = path.join(paths.root,'run') diff --git a/build/release.js b/build/release.js index cf2d245aa7..db73fc58e4 100644 --- a/build/release.js +++ b/build/release.js @@ -190,7 +190,7 @@ function engineVersion() { } function nightlyVersion() { - let changelog = changelog() + let changelog = new Changelog let version = changelog.entries[0].version if (version instanceof NextReleaseVersion) { version = changelog.entries[1].version diff --git a/build/run.js b/build/run.js index ce1ef07a16..05bc6a0390 100755 --- a/build/run.js +++ b/build/run.js @@ -344,16 +344,14 @@ commands['nightly-gen'].rust = async function(argv) { let appConfig = require('../config') appConfig.engineVersion = engineVersion - let appConfigPath = path.join(paths.root, 'config.json') console.log(`set engine version: ${engineVersion}`) console.log(`set IDE nightly version: ${nightlyVersion}`) // Update config.json - fss.writeFileSync(path.join(paths.root, 'config.json'), JSON.stringify(appConfig)) + fss.writeFileSync(paths.configJson, JSON.stringify(appConfig)) // Update changelog await cmd.run('sed', ['-i', `1s/.*/# Enso ${nightlyVersion} (${isoDate})`, paths.changelog]) - } // === CI Gen === From 0131067847f74c3edd4d4db9778c078191e5a928 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 12:47:50 +0300 Subject: [PATCH 24/33] fix: set changelog version --- build/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/run.js b/build/run.js index 05bc6a0390..b3a4a70b63 100755 --- a/build/run.js +++ b/build/run.js @@ -351,7 +351,7 @@ commands['nightly-gen'].rust = async function(argv) { // Update config.json fss.writeFileSync(paths.configJson, JSON.stringify(appConfig)) // Update changelog - await cmd.run('sed', ['-i', `1s/.*/# Enso ${nightlyVersion} (${isoDate})`, paths.changelog]) + await cmd.run('sed', ['-i', `'1s/.*/# Enso ${nightlyVersion} (${isoDate})/'`, paths.changelog]) } // === CI Gen === From 358373fb93548a66a500f524f6037484c3af84c1 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 12:51:11 +0300 Subject: [PATCH 25/33] fix: macOS build --- build/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/run.js b/build/run.js index b3a4a70b63..4b4c66cc1e 100755 --- a/build/run.js +++ b/build/run.js @@ -351,7 +351,7 @@ commands['nightly-gen'].rust = async function(argv) { // Update config.json fss.writeFileSync(paths.configJson, JSON.stringify(appConfig)) // Update changelog - await cmd.run('sed', ['-i', `'1s/.*/# Enso ${nightlyVersion} (${isoDate})/'`, paths.changelog]) + await cmd.run('sed', ['-i', '.bak', `'1s/.*/# Enso ${nightlyVersion} (${isoDate})/'`, paths.changelog]) } // === CI Gen === From 6adbfb6a3fa4ddb9bd29c3408264b64fa71c8b63 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 12:57:01 +0300 Subject: [PATCH 26/33] fix: version regex --- build/release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/release.js b/build/release.js index db73fc58e4..f1907b89c2 100644 --- a/build/release.js +++ b/build/release.js @@ -147,7 +147,7 @@ function changelogEntries() { let version = new NextReleaseVersion entries.push(new ChangelogEntry(version,body)) } else { - let headerReg = /^ Enso (?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)(-(?alpha|beta|rc)\.(?[0-9]+))?(.(?rc)\.(?[0-9]+))? \((?[0-9][0-9][0-9][0-9])-(?[0-9][0-9])-(?[0-9][0-9])\)/ + let headerReg = /^ Enso (?[0-9]+)\.(?[0-9]+)\.(?[0-9]+)(-(?alpha|beta|nightly|rc)\.(?[0-9-]+))?(.(?rc)\.(?[0-9]+))? \((?[0-9][0-9][0-9][0-9])-(?[0-9][0-9])-(?[0-9][0-9])\)/ let match = header.match(headerReg) if (!match) { throw `Improper changelog entry header: '${header}'. See the 'CHANGELOG_TEMPLATE.md' for details.` From 7ddf5529fbc24eef0e3a4afa128fcb41a9d26f4d Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 13:10:57 +0300 Subject: [PATCH 27/33] fix: run --- build/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/run.js b/build/run.js index 4b4c66cc1e..aa64f76149 100755 --- a/build/run.js +++ b/build/run.js @@ -351,7 +351,7 @@ commands['nightly-gen'].rust = async function(argv) { // Update config.json fss.writeFileSync(paths.configJson, JSON.stringify(appConfig)) // Update changelog - await cmd.run('sed', ['-i', '.bak', `'1s/.*/# Enso ${nightlyVersion} (${isoDate})/'`, paths.changelog]) + await cmd.run('sed', ["-i'.bak'", `'1s/.*/# Enso ${nightlyVersion} (${isoDate})/'`, paths.changelog]) } // === CI Gen === From bb1af34496be66859a15e9f91427623ffef1cb74 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 14:24:11 +0300 Subject: [PATCH 28/33] fix: version comparison --- .github/workflows/gui-ci.yml | 2 +- build/release.js | 25 ++++++++++++++++--------- build/workflow.js | 4 ++-- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index c6c0bc4c3c..56bfab7f06 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -504,7 +504,7 @@ jobs: tag_name: v${{fromJson(steps.changelog.outputs.content).version}} body: ${{fromJson(steps.changelog.outputs.content).body}} prerelease: ${{fromJson(steps.changelog.outputs.content).prerelease}} - draft: true + draft: ${{ ! (github.event.name == 'schedule' || true) }} - uses: dev-drprasad/delete-older-releases@v0.2.0 name: Remove Old Releases env: diff --git a/build/release.js b/build/release.js index f1907b89c2..7cbfc64291 100644 --- a/build/release.js +++ b/build/release.js @@ -39,20 +39,21 @@ class Version { this.minor = minor this.patch = patch this.tag = tag - this.tagVersion = parseInt(tagVersion) + this.tagVersion = tagVersion this.rcTag = rcTag this.rcTagVersion = rcTagVersion } lt(that) { - if (this.major < that.major) { return true } - if (this.minor < that.minor) { return true } - if (this.patch < that.patch) { return true } - if (this.tag === 'alpha' && that.tag === 'beta') { return true } - if (this.tag === 'alpha' && that.tag === 'rc') { return true } - if (this.tag === 'beta' && that.tag === 'rc') { return true } - if (this.tagVersion < that.tagVersion) { return true } - if (this.rcTagVersion < that.rcTagVersion) { return true } + if (this.major < that.major) { return true } + if (this.minor < that.minor) { return true } + if (this.patch < that.patch) { return true } + if (this.tag === 'nightly' && that.tag !== 'nightly') { return true } + if (this.tag === 'alpha' && that.tag === 'beta') { return true } + if (this.tag === 'alpha' && that.tag === 'rc') { return true } + if (this.tag === 'beta' && that.tag === 'rc') { return true } + if (ltStrings(this.tagVersion, that.tagVersion)) { return true } + if (ltStrings(this.rcTagVersion, that.rcTagVersion)) { return true } return false } @@ -72,7 +73,13 @@ class Version { } } +function ltStrings(version1, version2) { + let maxLength = Math.max(version1.length, version2.length) + let v1 = version1.padStart(maxLength, ' ') + let v2 = version2.padStart(maxLength, ' ') + return v1 < v2 +} // ====================== // === ChangelogEntry === diff --git a/build/workflow.js b/build/workflow.js index c76bc2eb97..a9c21dbde3 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -25,7 +25,7 @@ const FLAG_FORCE_CI_BUILD = '[ci build]' // === Conditions === // ================== -let nightlyReleaseCondition = `github.event.name == 'schedule' || true` +let nightlyReleaseCondition = "github.event.name == 'schedule' || true" /// Make a release only if it was a push to 'unstable' or 'stable'. Even if it was a pull request /// FROM these branches, the `github.ref` will be different. let releaseCondition = `${nightlyReleaseCondition} || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'` @@ -369,7 +369,7 @@ let uploadGitHubRelease = [ tag_name: "v${{fromJson(steps.changelog.outputs.content).version}}", body: "${{fromJson(steps.changelog.outputs.content).body}}", prerelease: "${{fromJson(steps.changelog.outputs.content).prerelease}}", - draft: true, + draft: `\${{ ! (${nightlyReleaseCondition}) }}`, }, } ] From d45da6901e5c6947e0b34f6a481d25950b0c32fd Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 14:29:35 +0300 Subject: [PATCH 29/33] fix: ordering --- build/release.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/release.js b/build/release.js index 7cbfc64291..6d5f0a4c87 100644 --- a/build/release.js +++ b/build/release.js @@ -48,7 +48,7 @@ class Version { if (this.major < that.major) { return true } if (this.minor < that.minor) { return true } if (this.patch < that.patch) { return true } - if (this.tag === 'nightly' && that.tag !== 'nightly') { return true } + if (this.tag === 'nightly' && that.tag !== 'nightly') { return false } if (this.tag === 'alpha' && that.tag === 'beta') { return true } if (this.tag === 'alpha' && that.tag === 'rc') { return true } if (this.tag === 'beta' && that.tag === 'rc') { return true } @@ -132,7 +132,9 @@ class Changelog { } currentVersion() { - return this.newestEntry().version + let v = this.newestEntry().version + console.log('currentVersion', v) + return v } } From b226fbeb4a8cbe0e1d14f810d87b662a04685b24 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 15:48:34 +0300 Subject: [PATCH 30/33] misc: cleanup --- .github/workflows/gui-ci.yml | 8 ++++---- build/release.js | 4 +--- build/run.js | 20 +++++++++----------- build/workflow.js | 4 ++-- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index 56bfab7f06..a098bf4b7a 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -47,8 +47,8 @@ jobs: run: |2- node ./run nightly-gen --skip-version-validation - cat config.json head CHANGELOG.md + cat config.json if: github.event.name == 'schedule' || true shell: bash @@ -301,8 +301,8 @@ jobs: run: |2- node ./run nightly-gen --skip-version-validation - cat config.json head CHANGELOG.md + cat config.json if: github.event.name == 'schedule' || true shell: bash @@ -463,8 +463,8 @@ jobs: run: |2- node ./run nightly-gen --skip-version-validation - cat config.json head CHANGELOG.md + cat config.json if: github.event.name == 'schedule' || true shell: bash @@ -541,8 +541,8 @@ jobs: run: |2- node ./run nightly-gen --skip-version-validation - cat config.json head CHANGELOG.md + cat config.json if: github.event.name == 'schedule' || true shell: bash diff --git a/build/release.js b/build/release.js index 6d5f0a4c87..def2d3dc4e 100644 --- a/build/release.js +++ b/build/release.js @@ -132,9 +132,7 @@ class Changelog { } currentVersion() { - let v = this.newestEntry().version - console.log('currentVersion', v) - return v + return this.newestEntry().version } } diff --git a/build/run.js b/build/run.js index aa64f76149..a69cd36398 100755 --- a/build/run.js +++ b/build/run.js @@ -4,6 +4,7 @@ const fs = require('fs').promises const fse = require('fs-extra') const fss = require('fs') const unzipper = require('unzipper') +const github = require('./github') const glob = require('glob') const ncp = require('ncp').ncp const os = require('os') @@ -331,27 +332,24 @@ commands.dist.js = async function() { // === Nightly Gen === commands['nightly-gen'] = command(`Generate Nightly CI build related files`) commands['nightly-gen'].rust = async function(argv) { - let github = require('./github') let nightlies = await github.fetchEngineNightlies() let engineVersion = nightlies[0].name - let nightlyPrefix = "Enso Nightly " + let nightlyPrefix = 'Enso Nightly ' if (engineVersion.startsWith(nightlyPrefix)) { engineVersion = engineVersion.substring(nightlyPrefix.length) } - let isoDate = release.isoDate() - let nightlyVersion = release.nightlyVersion() - - let appConfig = require('../config') - appConfig.engineVersion = engineVersion + let config = require('../config.json') + config.engineVersion = engineVersion - console.log(`set engine version: ${engineVersion}`) - console.log(`set IDE nightly version: ${nightlyVersion}`) + let nightlyVersion = release.nightlyVersion() + console.log(`engine version: ${engineVersion}`) + console.log(`IDE nightly version: ${nightlyVersion}`) // Update config.json - fss.writeFileSync(paths.configJson, JSON.stringify(appConfig)) + fss.writeFileSync(paths.configJson, JSON.stringify(config)) // Update changelog - await cmd.run('sed', ["-i'.bak'", `'1s/.*/# Enso ${nightlyVersion} (${isoDate})/'`, paths.changelog]) + await cmd.run('sed', ["-i'.bak'", `'1s/.*/# Enso ${nightlyVersion} (${release.isoDate()})/'`, paths.changelog]) } // === CI Gen === diff --git a/build/workflow.js b/build/workflow.js index a9c21dbde3..99f4fc8744 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -318,10 +318,10 @@ let setupNightly = { }, run: ` node ./run nightly-gen --skip-version-validation - cat config.json head CHANGELOG.md + cat config.json `, - if: `${nightlyReleaseCondition}`, + if: nightlyReleaseCondition, shell: 'bash', } From 61d2f9eac250f39182ad98c4e5c9281c47a27686 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 16:52:06 +0300 Subject: [PATCH 31/33] misc: cleanup --- .github/workflows/gui-ci.yml | 31 +++++++++++++++---------------- build/workflow.js | 6 +++--- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/.github/workflows/gui-ci.yml b/.github/workflows/gui-ci.yml index a098bf4b7a..87175ebe74 100644 --- a/.github/workflows/gui-ci.yml +++ b/.github/workflows/gui-ci.yml @@ -12,10 +12,9 @@ env: - develop - unstable - stable - - wip/db/nightly-release pull_request: {} schedule: - - cron: 0 7 * * 2-6 + - cron: 0 6 * * 2-6 jobs: info: name: Build Info @@ -50,7 +49,7 @@ jobs: head CHANGELOG.md cat config.json - if: github.event.name == 'schedule' || true + if: github.event.name == 'schedule' shell: bash - name: Read changelog info id: changelog @@ -78,8 +77,8 @@ jobs: if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi if: >- - github.event.name == 'schedule' || true || github.base_ref == - 'unstable' || github.base_ref == 'stable' + github.event.name == 'schedule' || github.base_ref == 'unstable' || + github.base_ref == 'stable' - name: Get list of changed files id: changed_files run: |2- @@ -304,7 +303,7 @@ jobs: head CHANGELOG.md cat config.json - if: github.event.name == 'schedule' || true + if: github.event.name == 'schedule' shell: bash - name: Read changelog info id: changelog @@ -441,7 +440,7 @@ jobs: contains(github.event.pull_request.body,'[ci build]') || contains(github.event.head_commit.message,'[ci build]') || github.ref == 'refs/heads/develop' || github.base_ref == 'unstable' || github.base_ref - == 'stable' || (github.event.name == 'schedule' || true || github.ref == + == 'stable' || (github.event.name == 'schedule' || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable') release_to_github: name: GitHub Release @@ -466,7 +465,7 @@ jobs: head CHANGELOG.md cat config.json - if: github.event.name == 'schedule' || true + if: github.event.name == 'schedule' shell: bash - name: Read changelog info id: changelog @@ -488,8 +487,8 @@ jobs: if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]]; then exit 1; fi if: >- - github.event.name == 'schedule' || true || github.base_ref == - 'unstable' || github.base_ref == 'stable' + github.event.name == 'schedule' || github.base_ref == 'unstable' || + github.base_ref == 'stable' - name: Install Prettier run: npm install --save-dev --save-exact prettier - name: Pretty print changelog. @@ -504,7 +503,7 @@ jobs: tag_name: v${{fromJson(steps.changelog.outputs.content).version}} body: ${{fromJson(steps.changelog.outputs.content).body}} prerelease: ${{fromJson(steps.changelog.outputs.content).prerelease}} - draft: ${{ ! (github.event.name == 'schedule' || true) }} + draft: ${{ ! (github.event.name == 'schedule') }} - uses: dev-drprasad/delete-older-releases@v0.2.0 name: Remove Old Releases env: @@ -514,8 +513,8 @@ jobs: delete_tag_pattern: nightly delete_tags: true if: >- - github.event.name == 'schedule' || true || github.ref == - 'refs/heads/unstable' || github.ref == 'refs/heads/stable' + github.event.name == 'schedule' || github.ref == 'refs/heads/unstable' || + github.ref == 'refs/heads/stable' needs: - version_assertions - lint @@ -544,7 +543,7 @@ jobs: head CHANGELOG.md cat config.json - if: github.event.name == 'schedule' || true + if: github.event.name == 'schedule' shell: bash - name: Read changelog info id: changelog @@ -591,8 +590,8 @@ jobs: s3://ensocdn/ide/${{fromJson(steps.changelog.outputs.content).version}}/wasm_imports.js.gz --profile s3-upload --acl public-read --content-encoding gzip if: >- - github.event.name == 'schedule' || true || github.ref == - 'refs/heads/unstable' || github.ref == 'refs/heads/stable' + github.event.name == 'schedule' || github.ref == 'refs/heads/unstable' || + github.ref == 'refs/heads/stable' needs: - version_assertions - lint diff --git a/build/workflow.js b/build/workflow.js index 99f4fc8744..3c22521119 100644 --- a/build/workflow.js +++ b/build/workflow.js @@ -25,7 +25,7 @@ const FLAG_FORCE_CI_BUILD = '[ci build]' // === Conditions === // ================== -let nightlyReleaseCondition = "github.event.name == 'schedule' || true" +let nightlyReleaseCondition = `github.event.name == 'schedule'` /// Make a release only if it was a push to 'unstable' or 'stable'. Even if it was a pull request /// FROM these branches, the `github.ref` will be different. let releaseCondition = `${nightlyReleaseCondition} || github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'` @@ -486,12 +486,12 @@ let workflow = { }, on: { push: { - branches: ['develop','unstable','stable','wip/db/nightly-release'], + branches: ['develop','unstable','stable'], }, pull_request: {}, schedule: [ { - cron: '0 7 * * 2-6' + cron: '0 6 * * 2-6' }, ] }, From f0dd57ad494526b35a3191a5ac1104b45c4e18a7 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 17:01:31 +0300 Subject: [PATCH 32/33] misc: doc --- build/github.js | 19 ------------------- build/release.js | 4 ++++ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/build/github.js b/build/github.js index c2d561c795..8b5a774d00 100644 --- a/build/github.js +++ b/build/github.js @@ -5,25 +5,6 @@ const engineRepo = 'enso' const token = process.env.GITHUB_TOKEN const octokit = new Octokit({ auth: token }) -function determineRepositoryName() { - const fallback = "ide" - const fallbackMessage = - "Could not determine the repository name, falling back to the default." - const fullName = process.env.GITHUB_REPOSITORY; - if (!fullName) { - console.log(fallbackMessage) - return fallback - } - - const prefix = organization + "/" - if (fullName.startsWith(prefix)) { - return fullName.substring(prefix.length) - } else { - console.log(fallbackMessage) - return fallback - } -} - function isNightly(release) { const nightlyInfix = "Nightly" return release.name.indexOf(nightlyInfix) >= 0 && !release.draft diff --git a/build/release.js b/build/release.js index def2d3dc4e..bbdd0d1217 100644 --- a/build/release.js +++ b/build/release.js @@ -73,6 +73,7 @@ class Version { } } +/// Compare two versions lexicographically. function ltStrings(version1, version2) { let maxLength = Math.max(version1.length, version2.length) let v1 = version1.padStart(maxLength, ' ') @@ -192,10 +193,12 @@ function currentVersion() { return changelog().currentVersion() } +/// Get the engine version. function engineVersion() { return config.engineVersion } +/// Create the nightly version based on the last version in changelog. function nightlyVersion() { let changelog = new Changelog let version = changelog.entries[0].version @@ -206,6 +209,7 @@ function nightlyVersion() { return `${version.major}.${version.minor}.${version.patch}-nightly.${isoDate()}` } +/// Get the current ISO date in format `YYYY-MM-DD`. function isoDate() { let date = new Date() return date.toISOString().split('T')[0] From c73f765a9042f962a5058669f6355882b8766251 Mon Sep 17 00:00:00 2001 From: Dmitry Bushev Date: Thu, 9 Sep 2021 17:17:44 +0300 Subject: [PATCH 33/33] misc: changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bad2af86c8..a39ff40f1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@
![New Features](/docs/assets/tags/new_features.svg) +- [Nightly releases.][1834] After every workday, CI performs an IDE build and + publishes a nightly pre-release on GitHub. +
![Bug Fixes](/docs/assets/tags/bug_fixes.svg) #### Visual Environment @@ -11,6 +14,7 @@ and `--data-gathering=true` are supported as well. [1831]: https://github.com/enso-org/ide/pull/1831 +[1834]: https://github.com/enso-org/ide/pull/1834 # Enso 2.0.0-alpha.14 (2021-09-02)