5
0
Fork 0
mirror of https://github.com/cycjimmy/semantic-release-action.git synced 2025-11-07 02:36:55 +00:00

feat: come a new action

This commit is contained in:
cycjimmy 2019-10-17 19:27:21 +08:00
parent d9823e84f7
commit b9ad41da60
17 changed files with 5822 additions and 2 deletions

15
.editorconfig Normal file
View file

@ -0,0 +1,15 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

2
.github/CONTRIBUTING.md vendored Normal file
View file

@ -0,0 +1,2 @@
# Contributing
The repository is released under the MIT license, and follows a standard Github development process, using Github tracker for issues and merging pull requests into master.

35
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View file

@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.

View file

@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

15
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,15 @@
### Type of Change
<!-- What type of change does your code introduce? -->
- [ ] New feature
- [ ] Bug fix
- [ ] Documentation
- [ ] Refactor
- [ ] Chore
### Resolves
- Fixes #[Add issue number here.]
### Describe Changes
<!-- Describe your changes in detail, if applicable. -->
_Describe what this Pull Request does_

60
.gitignore vendored Normal file
View file

@ -0,0 +1,60 @@
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# IDE
.idea/
# nodejs
node_modules/
npm-debug.log
yarn-error.log
# project
.publish
dist

17
.npmignore Normal file
View file

@ -0,0 +1,17 @@
# IDE
.idea
.editorconfig
# doc
.github
# test
test
.travis.yml
# node
yarn.lock
yarn-error.log
# project
*.config.js

46
CODE_OF_CONDUCT.md Normal file
View file

@ -0,0 +1,46 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at cycjimmy@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View file

@ -1,2 +1,18 @@
# semantic-release-action
Semantic Release Action
# Semantic Release Action
GitHub Action for [Semantic Release](https://github.com/semantic-release/semantic-release).
## Usage
* `branch`: [Optional] The branch for release. Default `"master"`.
* `extra_plugins`: [Optional] Extra plugins for pre-install. Default `""`.
```yaml
steps:
- name: Semantic Release
uses: cycjimmy/semantic-release-action@master
with:
branch: master
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
```

16
action.yml Normal file
View file

@ -0,0 +1,16 @@
name: 'Semantic Release Action'
description: 'GitHub Action for Semantic Release'
author: 'cycjimmy'
branding:
icon: 'package'
color: 'orange'
inputs:
branch:
description: 'The branch for release'
default: master
extra_plugins:
description: 'Extra plugins for pre-install'
default: ''
runs:
using: 'node12'
main: 'index.js'

0
docs/CHANGELOG.md Normal file
View file

19
index.js Normal file
View file

@ -0,0 +1,19 @@
const exec = require('./src/_exec');
const path = require('path');
const run = async () => {
// Install Dependencies
{
const {stdout, stderr} = await exec('npm ci --only=prod', {
cwd: path.resolve(__dirname)
});
console.log(stdout);
if (stderr) {
return Promise.reject(stderr);
}
}
require('./src/index')();
};
run().catch(console.error);

5460
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

27
package.json Normal file
View file

@ -0,0 +1,27 @@
{
"name": "@cycjimmy/semantic-release-action",
"version": "0.0.1-devlopment.1",
"description": "GitHub Action for Semantic Release",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/cycjimmy/semantic-release-action.git"
},
"keywords": [
"semantic-release",
"action"
],
"author": "cycjimmy <cycjimmy@gmail.com> (https://github.com/cycjimmy)",
"license": "MIT",
"bugs": {
"url": "https://github.com/cycjimmy/semantic-release-action/issues"
},
"homepage": "https://github.com/cycjimmy/semantic-release-action#readme",
"dependencies": {
"@actions/core": "^1.1.3",
"semantic-release": "^15.13.24"
}
}

24
release.config.js Normal file
View file

@ -0,0 +1,24 @@
module.exports = {
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "docs/CHANGELOG.md"
}
],
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": [
"docs/CHANGELOG.md",
"package.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
};

2
src/_exec.js Normal file
View file

@ -0,0 +1,2 @@
const util = require('util');
module.exports = util.promisify(require('child_process').exec);

49
src/index.js Normal file
View file

@ -0,0 +1,49 @@
const exec = require('./_exec');
const path = require('path');
const {WritableStreamBuffer} = require('stream-buffers');
const core = require('@actions/core');
const semanticRelease = require('semantic-release');
const release = async () => {
const branch = core.getInput('branch', {required: false}) || 'master';
const extraPlugins = core.getInput('extra_plugins', {required: false}) || '';
// pre-install plugins
if (extraPlugins) {
const _extraPlugins = extraPlugins
.replace(/['"]/g, '')
.replace(/[\n\r]/g, ' ');
const {stdout, stderr} = await exec(`npm install ${_extraPlugins}`, {
cwd: path.resolve(__dirname)
});
console.log(stdout);
if (stderr) {
return Promise.reject(stderr);
}
}
const result = await semanticRelease({branch});
if (!result) {
core.debug('No release published.');
return;
}
const {lastRelease, commits, nextRelease, releases} = result;
core.debug(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`);
if (lastRelease.version) {
core.debug(`The last release was "${lastRelease.version}".`);
}
for (const release of releases) {
core.debug(`The release was published with plugin "${release.pluginName}".`);
}
};
module.exports = () => {
release().catch(core.setFailed);
};