Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Nightly releases #1834

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 69 additions & 5 deletions .github/workflows/gui-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

name: GUI CI
env:
NIGHTLIES_TO_KEEP: 20
'on':
push:
branches:
Expand All @@ -12,6 +14,8 @@ name: GUI CI
- stable
pull_request: {}
workflow_dispatch: {}
schedule:
- cron: 0 6 * * 2-6
jobs:
info:
name: Build Info
Expand Down Expand Up @@ -41,6 +45,17 @@ jobs:
- uses: actions/checkout@v1
with:
clean: false
- name: Setup nightly
env:
GITHUB_TOKEN: ${{ github.token }}
run: |2-

node ./run nightly-gen --skip-version-validation
head CHANGELOG.md
cat config.json

if: github.event.name == 'schedule'
shell: bash
- name: Read changelog info
id: changelog
run: |2-
Expand All @@ -66,7 +81,9 @@ jobs:
run: >-
if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]];
then exit 1; fi
if: github.base_ref == 'unstable' || github.base_ref == 'stable'
if: >-
github.event.name == 'schedule' || github.base_ref == 'unstable' ||
github.base_ref == 'stable'
- name: Get list of changed files
id: changed_files
run: |2-
Expand Down Expand Up @@ -294,6 +311,17 @@ jobs:
- uses: actions/checkout@v1
with:
clean: false
- name: Setup nightly
env:
GITHUB_TOKEN: ${{ github.token }}
run: |2-

node ./run nightly-gen --skip-version-validation
head CHANGELOG.md
cat config.json

if: github.event.name == 'schedule'
shell: bash
- name: Read changelog info
id: changelog
run: |2-
Expand Down Expand Up @@ -438,6 +466,17 @@ jobs:
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Setup nightly
env:
GITHUB_TOKEN: ${{ github.token }}
run: |2-

node ./run nightly-gen --skip-version-validation
head CHANGELOG.md
cat config.json

if: github.event.name == 'schedule'
shell: bash
- name: Read changelog info
id: changelog
run: |2-
Expand All @@ -457,7 +496,9 @@ jobs:
run: >-
if [[ ${{ steps.checkCurrentReleaseTag.outputs.exists }} == true ]];
then exit 1; fi
if: github.base_ref == 'unstable' || github.base_ref == 'stable'
if: >-
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.
Expand All @@ -472,8 +513,18 @@ 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
if: github.ref == 'refs/heads/unstable' || github.ref == 'refs/heads/stable'
draft: ${{ ! (github.event.name == 'schedule') }}
- uses: dev-drprasad/[email protected]
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'
needs:
- version_assertions
- lint
Expand All @@ -495,6 +546,17 @@ jobs:
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Setup nightly
env:
GITHUB_TOKEN: ${{ github.token }}
run: |2-

node ./run nightly-gen --skip-version-validation
head CHANGELOG.md
cat config.json

if: github.event.name == 'schedule'
shell: bash
- name: Read changelog info
id: changelog
run: |2-
Expand Down Expand Up @@ -539,7 +601,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: >-
github.event.name == 'schedule' || github.ref == 'refs/heads/unstable' ||
github.ref == 'refs/heads/stable'
needs:
- version_assertions
- lint
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Next Release

<br/>![New Features](/docs/assets/tags/new_features.svg)

#### Visual Environment

- [Nightly releases.][1834] After every workday, CI performs an IDE build and
publishes a nightly pre-release on GitHub.

<br/>![Bug Fixes](/docs/assets/tags/bug_fixes.svg)

#### Visual Environment
Expand All @@ -13,6 +20,7 @@
<br/>

[1776]: https://github.com/enso-org/ide/pull/1776
[1834]: https://github.com/enso-org/ide/pull/1834

# Enso 2.0.0-alpha.17 (2021-09-23)

Expand Down
31 changes: 31 additions & 0 deletions build/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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 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 }
1 change: 1 addition & 0 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions build/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ 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')
paths.script.root = path.join(paths.root,'build')
Expand Down
45 changes: 34 additions & 11 deletions build/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,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 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 }
if (ltStrings(this.tagVersion, that.tagVersion)) { return true }
if (ltStrings(this.rcTagVersion, that.rcTagVersion)) { return true }
return false
}

Expand All @@ -73,7 +74,14 @@ class Version {
}
}

/// Compare two versions lexicographically.
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 ===
Expand Down Expand Up @@ -148,7 +156,7 @@ function changelogEntries() {
let version = new NextReleaseVersion
entries.push(new ChangelogEntry(version,body))
} else {
let headerReg = /^ Enso (?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<patch>[0-9]+)(-(?<tag>alpha|beta|rc)\.(?<tagVersion>[0-9]+))?(.(?<rcTag>rc)\.(?<rcTagVersion>[0-9]+))? \((?<year>[0-9][0-9][0-9][0-9])-(?<month>[0-9][0-9])-(?<day>[0-9][0-9])\)/
let headerReg = /^ Enso (?<major>[0-9]+)\.(?<minor>[0-9]+)\.(?<patch>[0-9]+)(-(?<tag>alpha|beta|nightly|rc)\.(?<tagVersion>[0-9-]+))?(.(?<rcTag>rc)\.(?<rcTagVersion>[0-9]+))? \((?<year>[0-9][0-9][0-9][0-9])-(?<month>[0-9][0-9])-(?<day>[0-9][0-9])\)/
let match = header.match(headerReg)
if (!match) {
throw `Improper changelog entry header: '${header}'. See the 'CHANGELOG_TEMPLATE.md' for details.`
Expand Down Expand Up @@ -186,10 +194,25 @@ function currentVersion() {
return changelog().currentVersion()
}

/// Create the nightly version based on the last version in changelog.
function nightlyVersion() {
let changelog = new 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()}`
}

/// Get the current ISO date in format `YYYY-MM-DD`.
function isoDate() {
let date = new Date()
return date.toISOString().split('T')[0]
}

// ===============
// === Exports ===
// ===============

module.exports = {ENGINE_VERSION,Version,NextReleaseVersion,changelog,currentVersion}
module.exports = {ENGINE_VERSION,Version,NextReleaseVersion,changelog,currentVersion,nightlyVersion,isoDate}
28 changes: 26 additions & 2 deletions build/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -284,7 +285,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)
})

Expand Down Expand Up @@ -328,6 +329,29 @@ 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 nightlies = await github.fetchEngineNightlies()
let engineVersion = nightlies[0].name
let nightlyPrefix = 'Enso Nightly '
if (engineVersion.startsWith(nightlyPrefix)) {
engineVersion = engineVersion.substring(nightlyPrefix.length)
}

let config = require('../config.json')
config.engineVersion = engineVersion

let nightlyVersion = release.nightlyVersion()
console.log(`engine version: ${engineVersion}`)
console.log(`IDE nightly version: ${nightlyVersion}`)

// Update config.json
fss.writeFileSync(paths.configJson, JSON.stringify(config))
// Update changelog
await cmd.run('sed', ["-i'.bak'", `'1s/.*/# Enso ${nightlyVersion} (${release.isoDate()})/'`, paths.changelog])
}

// === CI Gen ===

/// The command is used by CI to generate the file `CURRENT_RELEASE_CHANGELOG.json`, which contains
Expand All @@ -339,7 +363,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};
let obj = {version,body,prerelease}
let json = JSON.stringify(obj)
fss.writeFileSync(path.join(paths.root,'CURRENT_RELEASE_CHANGELOG.json'),json)
}
Expand Down
Loading