diff --git a/README.md b/README.md index ca60459..6179fdd 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,30 @@ bump libs/xyz from 0.0.0 to 0.1.0 # creates a tag `libs/xyz/0.1.0` ``` +## Usage in GitHub Actions + +The following example shows a workflow using git-semver in GitHub Actions: + +```yaml +name: Bump + +jobs: + bump: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - uses: carlsberg/git-semver@v0.5.0 + with: + script: | + echo "Latest Version: $(git semver latest)" + echo "Next Version: $(git semver next)" + + git semver bump -u ${{ github.actor }} -P ${{ github.token }} +``` + ## License This project is released under the [MIT License](LICENSE). diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..13b1647 --- /dev/null +++ b/action.yml @@ -0,0 +1,32 @@ +name: Git SemVer +description: Installs and runs git-semver + +inputs: + script: + description: Shell script to run + required: true + +runs: + using: composite + steps: + - id: version + run: | + v="${{ github.action_ref }}" + v=$(echo "${v:1}") + echo "::set-output name=version::$v" + shell: bash + + - run: | + v="${{ steps.version.outputs.version }}" + url="https://github.com/carlsberg/git-semver/releases/download/v$v/git-semver_$v_Linux_x86_64.tar.gz" + curl -L "$url" >> git-semver.tar.gz + tar -xvzf git-semver.tar.gz + mkdir $HOME/.local/bin && mv git-semver $HOME/.local/bin + echo $HOME/.local/bin >> $GITHUB_PATH + shell: bash + + - run: | + echo '${{ inputs.runs }}' >> script.sh + chmod +x script.sh + ./script.sh + shell: bash