Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release): bumped indicator #3

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/ci-rel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI cog release

on:
workflow_dispatch: {}
push: {}

jobs:
no-bump-has-prev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: cocogitto-action
- name: Initialise repository
run: |
git init
git config --global user.name 'Mona Lisa'
git config --global user.email '[email protected]'
git commit --allow-empty -m 'feat: initial'
git tag '0.1.0'
echo 'cocogitto-action/' > .gitignore
echo '# Mona Lisa' > README.md
git add README.md .gitignore
git commit -m 'chore: add Mona Lisa docs'
- name: Run cocogitto-action
id: release
uses: ./cocogitto-action
with:
check: true
release: true
- name: Check outputs
run: |
[ "${{ steps.release.outputs.version }}" == '0.1.0' ] || exit 1
[ -z "${{ steps.release.outputs.bumped }}" ] || exit 1
no-bump-no-prev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: cocogitto-action
- name: Initialise repository
run: |
git init
git config --global user.name 'Mona Lisa'
git config --global user.email '[email protected]'
echo 'cocogitto-action/' > .gitignore
echo '# Mona Lisa' > README.md
git add README.md .gitignore
git commit -m 'chore: add Mona Lisa docs'
- name: Run cocogitto-action
id: release
uses: ./cocogitto-action
with:
check: true
release: true
- name: Check outputs
run: |
[ -z "${{ steps.release.outputs.version }}" ] || exit 1
[ -z "${{ steps.release.outputs.bumped }}" ] || exit 1
bump-no-prev:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: cocogitto-action
- name: Initialise repository
run: |
git init
git config --global user.name 'Mona Lisa'
git config --global user.email '[email protected]'
echo 'cocogitto-action/' > .gitignore
echo '# Mona Lisa' > README.md
git add README.md .gitignore
git commit -m 'feat: add Mona Lisa docs'
- name: Run cocogitto-action
id: release
uses: ./cocogitto-action
with:
check: true
release: true
- name: Check outputs
run: |
[ "${{ steps.release.outputs.version }}" == '0.1.0' ] || exit 1
[ "${{ steps.release.outputs.bumped }}" == 'true' ] || exit 1
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ You can also use this action to perform releases (calling `cog bump --auto` unde
git-user: 'Cog Bot'
git-user-email: '[email protected]'

# The version number is accessible as a github action output
- name: Print version
run: "echo '${{ steps.release.outputs.version }}'"
# The version number is accessible as the action output.
# Also the action output contains flag,
# indicating if version was bumped or not.
- name: Print version if changed
if: ${{ steps.release.outputs.bumped }}
run: |
echo "new version: ${{ steps.release.outputs.version }}"
```

Note that you probably want to set the `git-user` and `git-user-email` options to override the default the git signature for the release commit.
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ inputs:

outputs:
version:
description: Version released
description: Released version or previous version if not bumped.
value: ${{ steps.cog.outputs.version }}
bumped:
description: Indicates if the version was bumped.
value: ${{ steps.cog.outputs.bumped }}

runs:
using: composite
Expand Down
11 changes: 8 additions & 3 deletions cog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,15 @@ if [ "${CHECK}" = 'true' ]; then
fi
fi

if [ "${RELEASE}" = "true" ]; then
if [ "${RELEASE}" = 'true' ]; then
cog bump --auto || exit 1
VERSION="$(git describe --tags "$(git rev-list --tags --max-count=1)")"
echo "version=$VERSION" >> $GITHUB_OUTPUT
NEXT_VERSION=$(cog get-version 2>/dev/null || echo '')
# shellcheck disable=2086
echo "version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
if [ -n "${NEXT_VERSION}" ] && [ "${CURRENT_VERSION}" != "${NEXT_VERSION}" ]; then
# shellcheck disable=2086
echo 'bumped=true' >> $GITHUB_OUTPUT
fi
fi

if ( echo "${VERIFY}" | grep -Eiv '^([01]|(true)|(false))$' > /dev/null ) ; then
Expand Down
Loading