Merge pull request #997 from ciderapp/enhancement/circleci
Enhancement/circleci
This commit is contained in:
parent
af34fc84a9
commit
c593a49135
2 changed files with 177 additions and 69 deletions
|
@ -1,21 +1,26 @@
|
||||||
version: 2.1
|
version: 2.1
|
||||||
orbs: # adds orbs to your configuration
|
|
||||||
jira: circleci/jira@1.0.5 # invokes the Jira orb, making its commands accessible
|
executors:
|
||||||
branches:
|
cider-ci:
|
||||||
only:
|
|
||||||
- main
|
|
||||||
- develop
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
working_directory: ~/Cider
|
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:16
|
- image: circleci/node:16
|
||||||
|
working_directory: ~/Cider
|
||||||
|
|
||||||
|
orbs: # Add orbs to your configuration
|
||||||
|
jira: circleci/jira@1.0.5 # invokes the Jira orb, making its commands accessible
|
||||||
|
|
||||||
|
# The jobs for this project
|
||||||
|
jobs:
|
||||||
|
prepare-build:
|
||||||
|
executor: cider-ci
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run:
|
- run:
|
||||||
name: Set App Version
|
name: Set App Version
|
||||||
command: echo "export APP_VERSION=$(grep '"version":.*' package.json | cut -d '"' -f 4 | head -1)" >> $BASH_ENV
|
command: echo "export APP_VERSION=$(grep '"version":.*' package.json | cut -d '"' -f 4 | head -1)" >> $BASH_ENV
|
||||||
|
# - run:
|
||||||
|
# name: Rename Repository
|
||||||
|
# command: sed -i 's/github:ciderapp\/Cider/github:ciderapp\/cider-releases/' package.json
|
||||||
- run:
|
- run:
|
||||||
name: Update Package Managers
|
name: Update Package Managers
|
||||||
command: sudo npm update -g npm yarn
|
command: sudo npm update -g npm yarn
|
||||||
|
@ -24,7 +29,7 @@ jobs:
|
||||||
keys:
|
keys:
|
||||||
- yarn-packages-{{ checksum "cider.lock" }}
|
- yarn-packages-{{ checksum "cider.lock" }}
|
||||||
- run:
|
- run:
|
||||||
name: Install Dependencies
|
name: Install Node Dependencies
|
||||||
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
|
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
|
||||||
- save_cache:
|
- save_cache:
|
||||||
name: Save Yarn Package Cache
|
name: Save Yarn Package Cache
|
||||||
|
@ -32,37 +37,112 @@ jobs:
|
||||||
paths:
|
paths:
|
||||||
- ~/.cache/yarn
|
- ~/.cache/yarn
|
||||||
- run:
|
- run:
|
||||||
name: Install system build dependencies
|
name: TypeScript Compile
|
||||||
command: |
|
command: yarn build
|
||||||
sudo apt-get update -y
|
- persist_to_workspace:
|
||||||
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
# Must be an absolute path, or relative path from working_directory. This is a directory on the container which is
|
||||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
# taken to be the root directory of the workspace.
|
||||||
sudo apt-get install -y dpkg fakeroot wine64
|
root: .
|
||||||
sudo dpkg --add-architecture i386
|
# Must be relative path from root
|
||||||
sudo apt-get update -y
|
paths:
|
||||||
sudo apt-get install -y wine32
|
- node_modules
|
||||||
sudo apt install -y gh
|
- build
|
||||||
|
- resources
|
||||||
|
- yarn.lock
|
||||||
|
- package.json
|
||||||
|
- winget.json # winget.json is a file that is generated by the winget package manager
|
||||||
|
- LICENSE
|
||||||
|
- license.txt
|
||||||
|
|
||||||
|
build-linux:
|
||||||
|
executor: cider-ci
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: ~/Cider
|
||||||
- run:
|
- run:
|
||||||
name: Fix Versioning and Add Channel
|
name: Fix Versioning and Add Channel
|
||||||
command: yarn circle:script
|
command: yarn circle:script
|
||||||
- run:
|
|
||||||
name: TypeScript Compile
|
|
||||||
command: yarn build
|
|
||||||
- run:
|
- run:
|
||||||
name: Generate Builds (Linux)
|
name: Generate Builds (Linux)
|
||||||
command: yarn electron-builder -l -p never
|
command: yarn electron-builder -l -p never
|
||||||
post-steps:
|
post-steps:
|
||||||
- jira/notify
|
- jira/notify
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: .
|
||||||
|
paths:
|
||||||
|
- dist/*.deb
|
||||||
|
- dist/*.AppImage
|
||||||
|
- dist/*.snap
|
||||||
|
- dist/latest-linux.yml
|
||||||
|
|
||||||
|
build-windows:
|
||||||
|
executor: cider-ci
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: ~/Cider
|
||||||
|
- run:
|
||||||
|
name: Install Windows System Build Dependencies
|
||||||
|
command: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y dpkg fakeroot wine64
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y wine32
|
||||||
|
- run:
|
||||||
|
name: Fix Versioning and Add Channel
|
||||||
|
command: yarn circle:script
|
||||||
- run:
|
- run:
|
||||||
name: Generate Builds (Windows)
|
name: Generate Builds (Windows)
|
||||||
command: yarn electron-builder -w --x64 -p never
|
command: yarn electron-builder -w --x64 -p never
|
||||||
post-steps:
|
post-steps:
|
||||||
- jira/notify
|
- jira/notify
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: .
|
||||||
|
paths:
|
||||||
|
- dist/*.exe
|
||||||
|
- dist/Cider-Setup-*.exe.blockmap
|
||||||
|
- dist/latest.yml
|
||||||
|
|
||||||
|
build-winget:
|
||||||
|
executor: cider-ci
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: ~/Cider
|
||||||
|
- run:
|
||||||
|
name: Install Windows System Build Dependencies
|
||||||
|
command: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y dpkg fakeroot wine64
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt-get install -y wine32
|
||||||
|
- run:
|
||||||
|
name: Fix Versioning and Add Channel
|
||||||
|
command: yarn circle:script
|
||||||
- run:
|
- run:
|
||||||
name: Generate Builds (Winget)
|
name: Generate Builds (Winget)
|
||||||
command: yarn electron-builder --win -c winget.json -p never
|
command: yarn electron-builder --win -c winget.json -p never
|
||||||
post-steps:
|
post-steps:
|
||||||
- jira/notify
|
- jira/notify
|
||||||
|
- persist_to_workspace:
|
||||||
|
root: .
|
||||||
|
paths:
|
||||||
|
- dist/*.exe
|
||||||
|
- dist/Cider-Setup-winget-*.exe.blockmap
|
||||||
|
|
||||||
|
release:
|
||||||
|
executor: cider-ci
|
||||||
|
steps:
|
||||||
|
- attach_workspace:
|
||||||
|
at: ~/Cider/
|
||||||
|
- run:
|
||||||
|
name: Installing GitHub Command Line Interface
|
||||||
|
command: |
|
||||||
|
sudo apt-get update -y
|
||||||
|
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
||||||
|
sudo apt-get update -y
|
||||||
|
sudo apt install -y gh
|
||||||
- run:
|
- run:
|
||||||
name: Move Build Files
|
name: Move Build Files
|
||||||
command: |
|
command: |
|
||||||
|
@ -79,3 +159,38 @@ jobs:
|
||||||
name: Publish Release
|
name: Publish Release
|
||||||
command: |
|
command: |
|
||||||
gh release create "v${APP_VERSION}.${CIRCLE_BUILD_NUM}" --title "Cider Version ${APP_VERSION} - Build ${CIRCLE_BUILD_NUM} (${CIRCLE_BRANCH})" --generate-notes -R ciderapp/cider-releases ~/Cider/dist/artifacts/*.deb ~/Cider/dist/artifacts/*.AppImage ~/Cider/dist/artifacts/*.snap ~/Cider/dist/artifacts/*.exe ~/Cider/dist/artifacts/*.yml ~/Cider/dist/artifacts/*.blockmap
|
gh release create "v${APP_VERSION}.${CIRCLE_BUILD_NUM}" --title "Cider Version ${APP_VERSION} - Build ${CIRCLE_BUILD_NUM} (${CIRCLE_BRANCH})" --generate-notes -R ciderapp/cider-releases ~/Cider/dist/artifacts/*.deb ~/Cider/dist/artifacts/*.AppImage ~/Cider/dist/artifacts/*.snap ~/Cider/dist/artifacts/*.exe ~/Cider/dist/artifacts/*.yml ~/Cider/dist/artifacts/*.blockmap
|
||||||
|
|
||||||
|
# Orchestrate our job run sequence
|
||||||
|
workflows:
|
||||||
|
build_and_release:
|
||||||
|
jobs:
|
||||||
|
- prepare-build:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: main
|
||||||
|
- build-windows:
|
||||||
|
requires:
|
||||||
|
- prepare-build
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: main
|
||||||
|
- build-linux:
|
||||||
|
requires:
|
||||||
|
- prepare-build
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: main
|
||||||
|
- build-winget:
|
||||||
|
requires:
|
||||||
|
- prepare-build
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: main
|
||||||
|
- release:
|
||||||
|
requires:
|
||||||
|
- build-windows
|
||||||
|
- build-linux
|
||||||
|
- build-winget
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: main
|
||||||
|
|
|
@ -1,53 +1,46 @@
|
||||||
|
|
||||||
|
|
||||||
if (!process.env['CIRCLECI']) {
|
if (!process.env['CIRCLECI']) {
|
||||||
console.log(`[CIRCLECI SCRIPT] CircleCI not found... Aborting script`)
|
console.log(`[CIRCLECI SCRIPT] CircleCI not found... Aborting script`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let fs = require('fs')
|
const {readFileSync, writeFile} = require('fs')
|
||||||
|
const pkg = JSON.parse(readFileSync('package.json').toString());
|
||||||
|
|
||||||
|
let channel = process.env['CIRCLE_BRANCH'];
|
||||||
|
|
||||||
var data = fs.readFileSync('package.json');
|
|
||||||
var package = JSON.parse(data);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let channel;
|
|
||||||
if (process.env['CIRCLE_BRANCH'] === 'lts') {
|
if (process.env['CIRCLE_BRANCH'] === 'lts') {
|
||||||
channel = 'latest'
|
channel = 'latest'
|
||||||
} else if (process.env['CIRCLE_BRANCH'] === 'main') {
|
} else if (process.env['CIRCLE_BRANCH'] === 'main') {
|
||||||
channel = 'beta'
|
channel = 'beta'
|
||||||
} else if (process.env['CIRCLE_BRANCH'] === 'develop') {
|
} else if (process.env['CIRCLE_BRANCH'] === 'develop') {
|
||||||
channel = 'alpha'
|
channel = 'alpha'
|
||||||
} else {
|
|
||||||
channel = process.env['CIRCLE_BRANCH'] // It won't have auto update support
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel = channel.split('/').join('-')
|
||||||
|
|
||||||
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
|
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
|
||||||
var pvers = package.version.split('.')
|
const version = pkg.version.split('.');
|
||||||
package.version = `${pvers[0]}.${pvers[1]}.${pvers[2]}-${channel}.${process.env['CIRCLE_BUILD_NUM']}`
|
pkg.version = `${version[0]}.${version[1]}.${version[2]}-${channel}`
|
||||||
// package.build.channel = channel
|
// package.build.channel = channel
|
||||||
package.publish = {
|
pkg.publish = {
|
||||||
"provider": "github",
|
"provider": "github",
|
||||||
"repo": "cider-releases",
|
"repo": "cider-releases",
|
||||||
"owner": "ciderapp",
|
"owner": "ciderapp",
|
||||||
"vPrefixedTagName": true,
|
"vPrefixedTagName": true,
|
||||||
"tag": `v${package.version}`,
|
"tag": `v${pkg.version}`,
|
||||||
"channel": channel,
|
"channel": channel,
|
||||||
"releaseType": "release"
|
"releaseType": "release"
|
||||||
}
|
}
|
||||||
|
|
||||||
let {exec} = require('child_process')
|
const {exec} = require('child_process')
|
||||||
exec('echo $APP_VERSION', {env: {'APP_VERSION': package.version}}, function (error, stdout, stderr)
|
|
||||||
{
|
exec('echo $APP_VERSION', {env: {'APP_VERSION': pkg.version}}, function (error, stdout, stderr) {
|
||||||
console.log(stdout, stderr, error);
|
console.log(stdout, stderr, error);
|
||||||
});
|
});
|
||||||
fs.writeFile('package.json', JSON.stringify(package), err => {
|
|
||||||
|
writeFile('package.json', JSON.stringify(pkg), err => {
|
||||||
// error checking
|
// error checking
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
console.log(`VERSION CHANGED TO ${package.version}`);
|
console.log(`VERSION CHANGED TO ${pkg.version}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue