Skip to content

Commit

Permalink
Add Release Workflow (#4)
Browse files Browse the repository at this point in the history
* Cache dependencies

* Fix indentation and cache dependencies

* Add action to bump version number

* Formatting

* Fix name

* Rename

* Add release workflow

* Clean uo
  • Loading branch information
mgacy authored Dec 13, 2023
1 parent 321b774 commit af64f60
Show file tree
Hide file tree
Showing 6 changed files with 833 additions and 29 deletions.
29 changes: 0 additions & 29 deletions .github/Workflows/tests.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/actions/bump-version/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Bump Version

A GitHub Action to bump a given version number.

## Inputs

```yaml
inputs:
current-version:
description: The current semantic version number.
required: true
release-type:
description: Type of release. Must be one of `patch` | `minor` | `major`.
required: true
```
## Outputs
```yaml
outputs:
version:
description: The new version number.
```
## Example Usage
```yaml
name: Bump Version
on:
workflow_dispatch:
inputs:
release_type:
description: Type of release
type: choice
required: true
options:
- patch
- minor
- major
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Git Checkout main
uses: actions/checkout@v4

- name: Get latest release version
id: get_current_version
uses: actions/github-script@v7
with:
script: |
const { data: { tag_name } } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
})
return tag_name
- name: Bump version
id: bump
uses: ./.github/actions/bump-version
with:
bump-type: ${{ inputs.release_type }}
version: ${{ steps.get_current_version.outputs.result }}

- name: Push tag
uses: actions/github-script@v7
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.bump.outputs.version }}',
sha: context.sha
})
```
## Acknowledgments
Uses [semver-tool](https://github.com/fsaintjacques/semver-tool)
24 changes: 24 additions & 0 deletions .github/actions/bump-version/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Bump Version
description: Bumps a given version number.

inputs:
current-version:
description: The current semantic version number.
required: true
release-type:
description: Type of release. Must be one of `patch` | `minor` | `major`.
required: true

outputs:
version:
description: The new version number.
value: ${{ steps.bump.outputs.new-version }}

runs:
using: composite
steps:
- name: Bump Version
id: bump
shell: bash
run: |
echo "new-version=$( ${{ github.action_path }}/semver.sh bump ${{ inputs.release-type }} ${{ inputs.current-version }} )" >> $GITHUB_OUTPUT
Loading

0 comments on commit af64f60

Please sign in to comment.