This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added publish:win and publish:deb
- Loading branch information
Showing
9 changed files
with
160 additions
and
23 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
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,46 @@ | ||
import {Command, flags} from '@oclif/command' | ||
import * as qq from 'qqjs' | ||
|
||
import aws from '../../aws' | ||
import {log} from '../../log' | ||
import * as Tarballs from '../../tarballs' | ||
|
||
export default class PublishDeb extends Command { | ||
static description = 'publish deb package built with pack:deb' | ||
|
||
static flags = { | ||
root: flags.string({char: 'r', description: 'path to oclif CLI root', default: '.', required: true}), | ||
} | ||
|
||
async run() { | ||
const {flags} = this.parse(PublishDeb) | ||
const buildConfig = await Tarballs.buildConfig(flags.root) | ||
const {s3Config, version, config} = buildConfig | ||
const dist = buildConfig.dist('deb') | ||
if (await qq.exists([dist, 'Release'])) this.error('run "oclif-dev pack:deb" before publishing') | ||
const S3Options = { | ||
Bucket: s3Config.bucket!, | ||
ACL: 'public-read', | ||
} | ||
|
||
const remoteBase = buildConfig.channel === 'stable' ? 'apt' : `channels/${buildConfig.channel}/apt` | ||
const upload = (file: string) => { | ||
return aws.s3.uploadFile(file, {...S3Options, CacheControl: 'max-age=86400', Key: [remoteBase, file].join('/')}) | ||
} | ||
const debVersion = `${buildConfig.version.split('-')[0]}-1` | ||
const uploadDeb = async (arch: 'amd64' | 'i386') => { | ||
const deb = buildConfig.dist(`deb/${config.bin}_${debVersion}_${arch}.deb`) | ||
if (await qq.exists(deb)) await upload(deb) | ||
} | ||
await uploadDeb('amd64') | ||
await uploadDeb('i386') | ||
await upload('Packages.gz') | ||
await upload('Packages.xz') | ||
await upload('Packages.bz2') | ||
await upload('Release') | ||
await upload('InRelease') | ||
await upload('Release.gpg') | ||
|
||
log(`published deb ${version}`) | ||
} | ||
} |
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,34 @@ | ||
import {Command, flags} from '@oclif/command' | ||
import * as qq from 'qqjs' | ||
|
||
import aws from '../../aws' | ||
import {log} from '../../log' | ||
import * as Tarballs from '../../tarballs' | ||
|
||
export default class PublishWin extends Command { | ||
static description = 'publish windows installers built with pack:win' | ||
|
||
static flags = { | ||
root: flags.string({char: 'r', description: 'path to oclif CLI root', default: '.', required: true}), | ||
} | ||
|
||
async run() { | ||
const {flags} = this.parse(PublishWin) | ||
const buildConfig = await Tarballs.buildConfig(flags.root) | ||
const {s3Config, version, config} = buildConfig | ||
const S3Options = { | ||
Bucket: s3Config.bucket!, | ||
ACL: 'public-read', | ||
} | ||
|
||
let root = buildConfig.channel === 'stable' ? '' : `channels/${buildConfig.channel}/` | ||
const uploadWin = async (arch: 'x64' | 'x86') => { | ||
const exe = buildConfig.dist(`win/${config.bin}-v${buildConfig.version}-${arch}.exe`) | ||
if (await qq.exists(exe)) await aws.s3.uploadFile(exe, {...S3Options, CacheControl: 'max-age=86400', Key: `${root}${config.bin}-${arch}.exe`}) | ||
} | ||
await uploadWin('x64') | ||
await uploadWin('x86') | ||
|
||
log(`published win ${version}`) | ||
} | ||
} |
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,32 @@ | ||
import {test} from '@oclif/test' | ||
import * as qq from 'qqjs' | ||
|
||
const pjson = require('../../../package.json') | ||
const pjsonPath = require.resolve('../../../package.json') | ||
const originalVersion = pjson.version | ||
|
||
const skipIfWindows = process.platform === 'win32' ? test.skip() : test | ||
const testRun = `test-${Math.random().toString().split('.')[1].slice(0, 4)}` | ||
|
||
describe('publish:deb', () => { | ||
beforeEach(async () => { | ||
pjson.version = `${pjson.version}-${testRun}` | ||
await qq.writeJSON(pjsonPath, pjson) | ||
const root = qq.join(__dirname, '../../../tmp/test/publish') | ||
await qq.emptyDir(root) | ||
qq.cd(root) | ||
}) | ||
afterEach(async () => { | ||
qq.x(`aws s3 rm --recursive s3://oclif/dev-cli/channels/${testRun}`) | ||
qq.cd([__dirname, '../../..']) | ||
pjson.version = originalVersion | ||
await qq.writeJSON(pjsonPath, pjson) | ||
}) | ||
|
||
skipIfWindows | ||
.command(['pack:deb']) | ||
.command(['publish:deb']) | ||
.it('publishes valid releases', async () => { | ||
await qq.download(`https://oclif-staging.s3.amazonaws.com/channels/${testRun}/apt/Release`) | ||
}) | ||
}) |
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,36 @@ | ||
import {test} from '@oclif/test' | ||
import * as qq from 'qqjs' | ||
|
||
import {gitSha} from '../../../src/tarballs' | ||
|
||
const pjson = require('../../../package.json') | ||
const pjsonPath = require.resolve('../../../package.json') | ||
const originalVersion = pjson.version | ||
|
||
const skipIfWindows = process.platform === 'win32' ? test.skip() : test | ||
const testRun = `test-${Math.random().toString().split('.')[1].slice(0, 4)}` | ||
|
||
describe('publish:win', () => { | ||
beforeEach(async () => { | ||
pjson.version = `${pjson.version}-${testRun}` | ||
await qq.writeJSON(pjsonPath, pjson) | ||
const root = qq.join(__dirname, '../../../tmp/test/publish') | ||
await qq.emptyDir(root) | ||
qq.cd(root) | ||
}) | ||
afterEach(async () => { | ||
qq.x(`aws s3 rm --recursive s3://oclif/dev-cli/channels/${testRun}`) | ||
qq.cd([__dirname, '../../..']) | ||
pjson.version = originalVersion | ||
await qq.writeJSON(pjsonPath, pjson) | ||
}) | ||
|
||
skipIfWindows | ||
.command(['pack:win']) | ||
.command(['publish:win']) | ||
.it('publishes valid releases', async () => { | ||
const sha = await gitSha(process.cwd(), {short: true}) | ||
await qq.download(`https://oclif-staging.s3.amazonaws.com/channels/${testRun}/oclif-dev-v${pjson.version}.${sha}-x64.exe`) | ||
await qq.download(`https://oclif-staging.s3.amazonaws.com/channels/${testRun}/oclif-dev-v${pjson.version}.${sha}-x86.exe`) | ||
}) | ||
}) |
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