2024-09-06 01:47:14 +02:00
const { Arch } = require ( "electron-builder" ) ;
2024-07-18 03:42:49 +02:00
const pkg = require ( "./package.json" ) ;
const fs = require ( "fs" ) ;
const path = require ( "path" ) ;
2024-10-17 23:27:15 +02:00
const windowsShouldSign = ! ! process . env . SM _CODE _SIGNING _CERT _SHA1 _HASH ;
2024-07-18 03:42:49 +02:00
/ * *
* @ type { import ( 'electron-builder' ) . Configuration }
* @ see https : //www.electron.build/configuration/configuration
* /
const config = {
2024-08-30 19:13:40 +02:00
appId : pkg . build . appId ,
productName : pkg . productName ,
2024-09-20 06:38:10 +02:00
executableName : pkg . productName ,
2024-08-30 19:13:40 +02:00
artifactName : "${productName}-${platform}-${arch}-${version}.${ext}" ,
Add release channels (#385)
## New release flow
1. Run "Bump Version" workflow with the desired version bump and the
prerelease flag set to `true`. This will push a new version bump to the
target branch and create a new git tag.
- See below for more info on how the version bumping works.
2. A new "Build Helper" workflow run will kick off automatically for the
new tag. Once it is complete, test the new build locally by downloading
with the [download
script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/download-staged-artifact.sh).
3. Release the new build using the [publish
script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/publish-from-staging.sh).
This will trigger electron-updater to distribute the package to beta
users.
4. Run "Bump Version" again with a release bump (either `major`,
`minor`, or `patch`) and the prerelease flag set to `false`.
6. Release the new build to all channels using the [publish
script](https://github.com/wavetermdev/thenextwave/blob/main/scripts/artifacts/publish-from-staging.sh).
This will trigger electron-updater to distribute the package to all
users.
## Change Summary
Creates a new "Bump Version" workflow to manage versioning and tag
creation.
Build Helper is now automated.
### Version bumps
Updates the `version.cjs` script so that an argument can be passed to
trigger a version bump. Under the hood, this utilizes NPM's `semver`
package.
If arguments are present, the version will be bumped.
If only a single argument is given, the following are valid inputs:
- `none`: No-op.
- `patch`: Bumps the patch version.
- `minor`: Bumps the minor version.
- `major`: Bumps the major version.
- '1', 'true': Bumps the prerelease version.
If two arguments are given, the first argument must be either `none`,
`patch`, `minor`, or `major`. The second argument must be `1` or `true`
to bump the prerelease version.
### electron-builder
We are now using the release channels support in electron-builder. This
will automatically detect the channel being built based on the package
version to determine which channel update files need to be generated.
See
[here](https://www.electron.build/tutorials/release-using-channels.html)
for more information.
### Github Actions
#### Bump Version
This adds a new "Bump Version" workflow for managing versioning and
queuing new builds. When run, this workflow will bump the version,
create a new tag, and push the changes to the target branch. There is a
new dropdown when queuing the "Bump Version" workflow to select what
kind of version bump to perform. A bump must always be performed when
running a new build to ensure consistency.
I had to create a GitHub App to grant write permissions to our main
branch for the version bump commits. I've made a separate workflow file
to manage the version bump commits, which should help prevent tampering.
Thanks to using the GitHub API directly, I am able to make these commits
signed!
#### Build Helper
Build Helper is now triggered when new tags are created, rather than
being triggered automatically. This ensures we're always creating
artifacts from known checkpoints.
### Settings
Adds a new `autoupdate:channel` configuration to the settings file. If
unset, the default from the artifact will be used (should correspond to
the channel of the artifact when downloaded).
## Future Work
I want to add a release workflow that will automatically copy over the
corresponding version artifacts to the release bucket when a new GitHub
Release is created.
I also want to separate versions into separate subdirectories in the
release bucket so we can clean them up more-easily.
---------
Co-authored-by: wave-builder <builds@commandline.dev>
Co-authored-by: wave-builder[bot] <181805596+wave-builder[bot]@users.noreply.github.com>
2024-09-17 22:10:35 +02:00
generateUpdatesFilesForAllChannels : true ,
2024-08-30 19:13:40 +02:00
npmRebuild : false ,
nodeGypRebuild : false ,
electronCompile : false ,
files : [
{
from : "./dist" ,
to : "./dist" ,
2024-09-04 20:23:39 +02:00
filter : [ "**/*" , "!bin/*" , "bin/wavesrv.${arch}*" , "bin/wsh*" ] ,
2024-08-30 19:13:40 +02:00
} ,
{
from : "." ,
to : "." ,
filter : [ "package.json" ] ,
} ,
"!node_modules" , // We don't need electron-builder to package in Node modules as Vite has already bundled any code that our program is using.
] ,
directories : {
output : "make" ,
2024-07-18 03:42:49 +02:00
} ,
2024-08-30 19:13:40 +02:00
asarUnpack : [
"dist/bin/**/*" , // wavesrv and wsh binaries
2024-10-04 05:28:05 +02:00
"dist/docsite/**/*" , // the static docsite
2024-07-18 03:42:49 +02:00
] ,
2024-08-30 19:13:40 +02:00
mac : {
target : [
{
target : "zip" ,
arch : [ "universal" , "arm64" , "x64" ] ,
} ,
{
target : "dmg" ,
arch : [ "universal" , "arm64" , "x64" ] ,
} ,
] ,
category : "public.app-category.developer-tools" ,
minimumSystemVersion : "10.15.0" ,
2024-09-04 20:23:39 +02:00
mergeASARs : true ,
singleArchFiles : "dist/bin/wavesrv.*" ,
2024-11-01 20:17:19 +01:00
entitlements : "build/entitlements.mac.plist" ,
entitlementsInherit : "build/entitlements.mac.plist" ,
2024-10-31 22:36:02 +01:00
extendInfo : {
2024-11-01 20:17:19 +01:00
NSContactsUsageDescription : "A CLI application running in Wave wants to use your contacts." ,
NSRemindersUsageDescription : "A CLI application running in Wave wants to use your reminders." ,
NSLocationWhenInUseUsageDescription :
"A CLI application running in Wave wants to use your location information while active." ,
NSLocationAlwaysUsageDescription :
"A CLI application running in Wave wants to use your location information, even in the background." ,
NSCameraUsageDescription : "A CLI application running in Wave wants to use the camera." ,
NSMicrophoneUsageDescription : "A CLI application running in Wave wants to use your microphone." ,
NSCalendarsUsageDescription : "A CLI application running in Wave wants to use Calendar data." ,
NSLocationUsageDescription : "A CLI application running in Wave wants to use your location information." ,
NSAppleEventsUsageDescription : "A CLI application running in Wave wants to use AppleScript." ,
2024-10-31 20:34:30 +01:00
} ,
2024-08-30 19:13:40 +02:00
} ,
linux : {
2024-09-06 00:41:04 +02:00
artifactName : "${name}-${platform}-${arch}-${version}.${ext}" ,
2024-08-30 19:13:40 +02:00
category : "TerminalEmulator" ,
2024-09-20 06:49:10 +02:00
executableName : pkg . name ,
2024-10-22 03:13:19 +02:00
target : [ "zip" , "deb" , "rpm" , "snap" , "AppImage" , "pacman" ] ,
2024-08-30 19:13:40 +02:00
synopsis : pkg . description ,
description : null ,
desktop : {
Name : pkg . productName ,
Comment : pkg . description ,
Keywords : "developer;terminal;emulator;" ,
category : "Development;Utility;" ,
} ,
2024-10-03 20:04:02 +02:00
executableArgs : [ "--enable-features" , "UseOzonePlatform" , "--ozone-platform-hint" , "auto" ] , // Hint Electron to use Ozone abstraction layer for native Wayland support
2024-08-30 19:13:40 +02:00
} ,
2024-09-25 06:26:16 +02:00
deb : {
afterInstall : "build/deb-postinstall.tpl" ,
} ,
2024-08-30 19:13:40 +02:00
win : {
target : [ "nsis" , "msi" , "zip" ] ,
2024-10-17 23:27:15 +02:00
signtoolOptions : windowsShouldSign && {
signingHashAlgorithms : [ "sha256" ] ,
publisherName : "Command Line Inc" ,
certificateSubjectName : "Command Line Inc" ,
certificateSha1 : process . env . SM _CODE _SIGNING _CERT _SHA1 _HASH ,
} ,
2024-08-30 19:13:40 +02:00
} ,
appImage : {
license : "LICENSE" ,
} ,
2024-10-22 03:13:19 +02:00
snap : {
base : "core22" ,
confinement : "classic" ,
allowNativeWayland : true ,
2024-10-24 20:25:45 +02:00
artifactName : "${name}_${version}_${arch}.${ext}" ,
2024-10-22 03:13:19 +02:00
} ,
2024-08-30 19:13:40 +02:00
publish : {
provider : "generic" ,
url : "https://dl.waveterm.dev/releases-w2" ,
2024-07-18 03:42:49 +02:00
} ,
2024-09-06 01:47:14 +02:00
afterPack : ( context ) => {
// This is a workaround to restore file permissions to the wavesrv binaries on macOS after packaging the universal binary.
if ( context . electronPlatformName === "darwin" && context . arch === Arch . universal ) {
2024-09-06 01:50:38 +02:00
const packageBinDir = path . resolve (
2024-09-06 01:47:14 +02:00
context . appOutDir ,
2024-09-20 06:51:24 +02:00
` ${ pkg . productName } .app/Contents/Resources/app.asar.unpacked/dist/bin `
2024-09-06 01:47:14 +02:00
) ;
// Reapply file permissions to the wavesrv binaries in the final app package
fs . readdirSync ( packageBinDir , {
recursive : true ,
withFileTypes : true ,
} )
. filter ( ( f ) => f . isFile ( ) && f . name . startsWith ( "wavesrv" ) )
2024-09-06 01:48:08 +02:00
. forEach ( ( f ) => fs . chmodSync ( path . resolve ( f . parentPath ? ? f . path , f . name ) , 0o755 ) ) ; // 0o755 corresponds to -rwxr-xr-x
2024-09-06 01:47:14 +02:00
}
} ,
2024-07-18 03:42:49 +02:00
} ;
module . exports = config ;