-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upload assets to GitHub release (#334)
* feat: upload assets to GitHub release * feat: accept function and glob pattern * fix: async runStep * fix: use releases instead of release * fix: quote path with spaces * test: add test for createGitHubRelease * test: fix test name * test: add eslint disable comment
- Loading branch information
Showing
9 changed files
with
284 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -183,4 +183,7 @@ export default { | |
], | ||
}), | ||
}, | ||
releases: { | ||
assetsToUpload: [], | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,3 +1,12 @@ | ||
module.exports = { | ||
presets: ['@babel/preset-env'], | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
node: 'current', | ||
}, | ||
}, | ||
], | ||
], | ||
}; |
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
51 changes: 51 additions & 0 deletions
51
packages/shipjs/src/step/release/__tests__/createGitHubRelease.test.js
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,51 @@ | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
import defaultConfig from 'shipjs-lib/src/lib/config/defaultConfig'; | ||
|
||
let stdout = ''; | ||
const mockedLog = (...args) => { | ||
stdout += args.join(' '); | ||
stdout += '\n'; | ||
}; | ||
|
||
beforeEach(() => { | ||
// eslint-disable-next-line no-console | ||
console.log = mockedLog; | ||
}); | ||
|
||
afterEach(() => { | ||
stdout = ''; | ||
}); | ||
|
||
it('create github release', async () => { | ||
const createGitHubRelease = require('../createGitHubRelease'); | ||
const dryRun = true; | ||
const dir = path.resolve(__dirname, 'fixtures'); | ||
const version = '0.5.5'; | ||
const config = { | ||
...defaultConfig, | ||
releases: { | ||
assetsToUpload: 'asset with spaces.md', | ||
}, | ||
}; | ||
await createGitHubRelease.default({ version, dryRun, config, dir }); | ||
const changelogPath = stdout.match(/-F ([^\s]+)/)[1]; | ||
const changelog = fs.readFileSync(changelogPath, 'utf-8'); | ||
|
||
expect(changelog).toEqual(`${version} | ||
## [${version}](https://example.com) (2019-10-01) | ||
### Bug Fixes | ||
- bug fixes | ||
`); | ||
|
||
expect(stdout).toContain( | ||
`-a '${path.join(dir, config.releases.assetsToUpload)}'` | ||
); | ||
}); |
22 changes: 22 additions & 0 deletions
22
packages/shipjs/src/step/release/__tests__/fixtures/CHANGELOG.md
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,22 @@ | ||
# [0.6.0](https://example.com/v0.5.5...v0.6.0) (2019-10-04) | ||
|
||
### Bug Fixes | ||
|
||
* don't do this ([#294](https://example.com)) ([eb1ab44](https://example.com)) | ||
* fix bug ([#301](https://example.com)) ([f89ba1d](https://example.com)) | ||
|
||
### Features | ||
|
||
* add hook ([#293](https://example.com)) ([0de5d68](https://example.com)) | ||
|
||
## [0.5.5](https://example.com) (2019-10-01) | ||
|
||
|
||
### Bug Fixes | ||
|
||
- bug fixes | ||
|
||
|
||
# 0.1.0 (2019-08-02) | ||
|
||
### Initial Release |
Empty file.
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
Oops, something went wrong.