Merge pull request #997 from ciderapp/enhancement/circleci

Enhancement/circleci
This commit is contained in:
Core 2022-05-07 05:58:37 +01:00
parent af34fc84a9
commit c593a49135
No known key found for this signature in database
GPG key ID: FE9BF1B547F8F3C6
2 changed files with 177 additions and 69 deletions

View file

@ -1,21 +1,26 @@
version: 2.1
orbs: # adds orbs to your configuration
jira: circleci/jira@1.0.5 # invokes the Jira orb, making its commands accessible
branches:
only:
- main
- develop
jobs:
build:
working_directory: ~/Cider
executors:
cider-ci:
docker:
- 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:
- checkout
- run:
name: Set App Version
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:
name: Update Package Managers
command: sudo npm update -g npm yarn
@ -24,7 +29,7 @@ jobs:
keys:
- yarn-packages-{{ checksum "cider.lock" }}
- run:
name: Install Dependencies
name: Install Node Dependencies
command: yarn install --frozen-lockfile --cache-folder ~/.cache/yarn
- save_cache:
name: Save Yarn Package Cache
@ -32,50 +37,160 @@ jobs:
paths:
- ~/.cache/yarn
- run:
name: Install system build dependencies
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 install -y dpkg fakeroot wine64
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install -y wine32
sudo apt install -y gh
name: TypeScript Compile
command: yarn build
- persist_to_workspace:
# Must be an absolute path, or relative path from working_directory. This is a directory on the container which is
# taken to be the root directory of the workspace.
root: .
# Must be relative path from root
paths:
- node_modules
- 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:
name: Fix Versioning and Add Channel
command: yarn circle:script
- run:
name: TypeScript Compile
command: yarn build
- run:
name: Generate Builds (Linux)
command: yarn electron-builder -l -p never
post-steps:
- 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:
name: Generate Builds (Windows)
command: yarn electron-builder -w --x64 -p never
post-steps:
- 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:
name: Generate Builds (Winget)
command: yarn electron-builder --win -c winget.json -p never
post-steps:
- 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:
name: Move Build Files
command: |
mkdir ~/Cider/dist/artifacts/
mv ~/Cider/dist/*.exe ~/Cider/dist/artifacts
mv ~/Cider/dist/*.deb ~/Cider/dist/artifacts
mv ~/Cider/dist/*.AppImage ~/Cider/dist/artifacts
mv ~/Cider/dist/*.snap ~/Cider/dist/artifacts
mv ~/Cider/dist/*.yml ~/Cider/dist/artifacts
mv ~/Cider/dist/*.blockmap ~/Cider/dist/artifacts
mkdir ~/Cider/dist/artifacts/
mv ~/Cider/dist/*.exe ~/Cider/dist/artifacts
mv ~/Cider/dist/*.deb ~/Cider/dist/artifacts
mv ~/Cider/dist/*.AppImage ~/Cider/dist/artifacts
mv ~/Cider/dist/*.snap ~/Cider/dist/artifacts
mv ~/Cider/dist/*.yml ~/Cider/dist/artifacts
mv ~/Cider/dist/*.blockmap ~/Cider/dist/artifacts
- store_artifacts:
path: ~/Cider/dist/artifacts
- run:
name: Publish Release
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

View file

@ -1,53 +1,46 @@
if (!process.env['CIRCLECI']) {
console.log(`[CIRCLECI SCRIPT] CircleCI not found... Aborting script`)
return
console.log(`[CIRCLECI SCRIPT] CircleCI not found... Aborting script`)
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') {
channel = 'latest'
channel = 'latest'
} else if (process.env['CIRCLE_BRANCH'] === 'main') {
channel = 'beta'
channel = 'beta'
} else if (process.env['CIRCLE_BRANCH'] === 'develop') {
channel = 'alpha'
} else {
channel = process.env['CIRCLE_BRANCH'] // It won't have auto update support
channel = 'alpha'
}
channel = channel.split('/').join('-')
// https://circleci.com/docs/2.0/env-vars/#built-in-environment-variables
var pvers = package.version.split('.')
package.version = `${pvers[0]}.${pvers[1]}.${pvers[2]}-${channel}.${process.env['CIRCLE_BUILD_NUM']}`
const version = pkg.version.split('.');
pkg.version = `${version[0]}.${version[1]}.${version[2]}-${channel}`
// package.build.channel = channel
package.publish = {
"provider": "github",
"repo": "cider-releases",
"owner": "ciderapp",
"vPrefixedTagName": true,
"tag": `v${package.version}`,
"channel": channel,
"releaseType": "release"
pkg.publish = {
"provider": "github",
"repo": "cider-releases",
"owner": "ciderapp",
"vPrefixedTagName": true,
"tag": `v${pkg.version}`,
"channel": channel,
"releaseType": "release"
}
let {exec} = require('child_process')
exec('echo $APP_VERSION', {env: {'APP_VERSION': package.version}}, function (error, stdout, stderr)
{
console.log(stdout, stderr, error);
});
fs.writeFile('package.json', JSON.stringify(package), err => {
// error checking
if(err) throw err;
console.log(`VERSION CHANGED TO ${package.version}`);
const {exec} = require('child_process')
exec('echo $APP_VERSION', {env: {'APP_VERSION': pkg.version}}, function (error, stdout, stderr) {
console.log(stdout, stderr, error);
});
writeFile('package.json', JSON.stringify(pkg), err => {
// error checking
if (err) throw err;
console.log(`VERSION CHANGED TO ${pkg.version}`);
});