forked from electron/forge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(publisher): add snapcraft publisher
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import Snapcraft from 'electron-installer-snap/snapcraft'; | ||
|
||
import asyncOra from '../util/ora-handler'; | ||
|
||
/** | ||
* `forgeConfig.snapStore`: | ||
* * `release`: comma-separated list of channels to release to | ||
*/ | ||
export default async ({ dir, artifacts, forgeConfig }) => { | ||
const snapArtifacts = artifacts.filter(artifact => artifact.endsWith('.snap')); | ||
|
||
if (snapArtifacts.length === 0) { | ||
throw 'No snap files to upload!'; | ||
} | ||
|
||
const snapcraftCfgPath = path.join(dir, '.snapcraft', 'snapcraft.cfg'); | ||
|
||
if (!await fs.pathExists(snapcraftCfgPath)) { | ||
throw 'Snapcraft config not found!'; | ||
} | ||
|
||
await asyncOra('Pushing snap to the snap store', async () => { | ||
const snapcraft = new Snapcraft(); | ||
await snapcraft.run(dir, 'push', forgeConfig.snapStore, snapArtifacts); | ||
}); | ||
}; |