Skip to content

Commit

Permalink
feat: refactor to tag and release in the action
Browse files Browse the repository at this point in the history
  • Loading branch information
meysam81 committed Jan 3, 2024
1 parent c2ea050 commit 40def1f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 26 deletions.
27 changes: 2 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,8 @@ jobs:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout with all the tags
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch the latest semantic version tag
id: semver
run: echo "latest-tag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_OUTPUT
- name: Bump me
id: bump
uses: licenseware/bump-version@main
with:
version: ${{ steps.semver.outputs.latest-tag }}
- name: Configure git
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
# - name: Fetch GPG Key
# run: |
# echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --import
- name: Tag and push
run: |
git tag -a ${{ steps.bump.outputs.version }} -m "Bump version to ${{ steps.bump.outputs.version }}"
git push origin ${{ steps.bump.outputs.version }}
- name: Create a GitHub release from tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.bump.outputs.version }} --title "${{ steps.bump.outputs.version }}" --generate-notes --latest
tag: "true"
release: "true"
38 changes: 37 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,56 @@ branding:
icon: arrow-up
description: Bump patch version of a semantic version
inputs:
tag:
description: "Whether or not to commit the tag and push to the repository (truthy values: true, yes, 1)"
required: false
default: ""
release:
description: "Whether or not to create a GitHub release from the tag (truthy values: true, yes, 1)"
required: false
default: ""
version:
description: Semantic versioning to bump
required: true
required: false
default: ""
outputs:
version:
description: Bumped semantic version
value: ${{ steps.bump.outputs.version }}
runs:
using: composite
steps:
- name: Checkout
if: inputs.version == ''
uses: actions/checkout@v4
- name: Fetch the latest semantic version tag
if: inputs.version == ''
id: semver
shell: bash
run: echo "latest-tag=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_OUTPUT
- name: Bump version
shell: bash
id: bump
run: |
current_version="${{ inputs.version }}"
bumped=$(echo $current_version | awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)
echo "version=${bumped}" >> $GITHUB_OUTPUT
- name: Configure git
if: contains(fromJSON('["true", "yes", "1"]'), inputs.tag)
shell: bash
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
- name: Tag and push
if: contains(fromJSON('["true", "yes", "1"]'), inputs.tag)
shell: bash
run: |
git tag -a ${{ steps.bump.outputs.version }} -m "Bump version to ${{ steps.bump.outputs.version }}"
git push origin ${{ steps.bump.outputs.version }}
- name: Create a GitHub release from tag
if: contains(fromJSON('["true", "yes", "1"]'), inputs.release)
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create ${{ steps.bump.outputs.version }} --title "${{ steps.bump.outputs.version }}" --generate-notes --latest

0 comments on commit 40def1f

Please sign in to comment.