Skip to content

Commit 0ce9865

Browse files
authored
feat(gh-actions): add support for GitHub Actions (#37)
1 parent 27e9eac commit 0ce9865

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ bump libs/xyz from 0.0.0 to 0.1.0
7676
# creates a tag `libs/xyz/0.1.0`
7777
```
7878

79+
## Usage in GitHub Actions
80+
81+
The following example shows a workflow using git-semver in GitHub Actions:
82+
83+
```yaml
84+
name: Bump
85+
86+
jobs:
87+
bump:
88+
runs-on: ubuntu-latest
89+
steps:
90+
- uses: actions/checkout@v2
91+
with:
92+
fetch-depth: 0
93+
94+
- uses: carlsberg/[email protected]
95+
with:
96+
script: |
97+
echo "Latest Version: $(git semver latest)"
98+
echo "Next Version: $(git semver next)"
99+
100+
git semver bump -u ${{ github.actor }} -P ${{ github.token }}
101+
```
102+
79103
## License
80104
81105
This project is released under the [MIT License](LICENSE).

action.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Git SemVer
2+
description: Installs and runs git-semver
3+
4+
inputs:
5+
script:
6+
description: Shell script to run
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- id: version
13+
run: |
14+
v="${{ github.action_ref }}"
15+
v=$(echo "${v:1}")
16+
echo "::set-output name=version::$v"
17+
shell: bash
18+
19+
- run: |
20+
v="${{ steps.version.outputs.version }}"
21+
url="https://github.com/carlsberg/git-semver/releases/download/v$v/git-semver_$v_Linux_x86_64.tar.gz"
22+
curl -L "$url" >> git-semver.tar.gz
23+
tar -xvzf git-semver.tar.gz
24+
mkdir $HOME/.local/bin && mv git-semver $HOME/.local/bin
25+
echo $HOME/.local/bin >> $GITHUB_PATH
26+
shell: bash
27+
28+
- run: |
29+
echo '${{ inputs.runs }}' >> script.sh
30+
chmod +x script.sh
31+
./script.sh
32+
shell: bash

0 commit comments

Comments
 (0)