Skip to content

Commit 1ce5ea9

Browse files
initial commit
0 parents  commit 1ce5ea9

8 files changed

Lines changed: 678 additions & 0 deletions

File tree

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
.idea

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Generate semver - Github action
2+
3+
A [GitHub Action](https://github.com/features/actions) to generate semantic version number.
4+
and commit messages.
5+
6+
## Usage
7+
8+
1. Create a `.github/workflows/generate-version.yml` file in your GitHub repo.
9+
2. Add the following code to the `generate-version.yml` file.
10+
11+
```yml
12+
on:
13+
pull_request:
14+
types:
15+
- opened
16+
- synchronize
17+
- reopened
18+
- ready_for_review
19+
branches:
20+
- master
21+
22+
jobs:
23+
attach:
24+
runs-on: ubuntu-18.04
25+
timeout-minutes: 10
26+
if: github.event.pull_request.draft == false
27+
28+
steps:
29+
- uses: actions/checkout@v2
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Generate branch diff file
34+
if: success()
35+
run: |
36+
echo "Head branch: ${GITHUB_HEAD_REF}"
37+
echo "Base branch: ${GITHUB_BASE_REF}"
38+
git log origin/${GITHUB_BASE_REF}..origin/${GITHUB_HEAD_REF} > ./branch-diff.txt
39+
40+
- name: Extract previous version
41+
if: success()
42+
run: |
43+
export PREVIOUS_VERSION=$(git describe --tags --abbrev=0)
44+
echo "Previous version: ${PREVIOUS_VERSION}"
45+
echo "PREVIOUS_VERSION=${TAG}" > ${GITHUB_ENV}
46+
47+
- name: Generate version number
48+
id: generate
49+
if: success()
50+
uses: juztcode/generate-semver@1.0.0
51+
with:
52+
branch-diff-file: ./branch-diff.txt
53+
previous-version: ${{ env.PREVIOUS_VERSION }}
54+
55+
- name: Print version
56+
- if: success()
57+
run: echo ${{ steps.generate.outputs.generated-version }}
58+
```
59+
60+
> Note: This will be triggered when there are pull requests from release branches to master branch and update pull request body with jira ticket ids.
61+
62+
## Inputs
63+
64+
Input | Purpose
65+
------------------|---------------------------------------------------------------------------------------------------------------------------------------
66+
branch-diff-file | File contains commit message difference between head and base branches.
67+
previous-version | Previous (latest) version number.
68+
69+
## Outputs
70+
71+
Output | Purpose
72+
------------------|---------------------------------------------------------------------------------------------------------------------------------------
73+
generated-version | Generated semver version number.

action.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
name: 'Generate semver'
3+
description: 'Generate semver from commit messages'
4+
author: 'randilfernando<randil.fernando@outlook.com>'
5+
runs:
6+
using: 'node12'
7+
main: 'dist/index.js'
8+
inputs:
9+
branch-diff-file:
10+
description: 'The branch diff file'
11+
required: true
12+
previous-version:
13+
description: 'Previous released version'
14+
required: true
15+
outputs:
16+
generated-version:
17+
description: 'Generated semver version number'

0 commit comments

Comments
 (0)