Check Version #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Version | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- app/package.json | |
jobs: | |
check-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install jq | |
run: sudo apt-get install -y jq | |
- name: Get current and previous versions | |
id: version_check | |
run: | | |
CURRENT_VERSION=$(jq -r '.version' app/package.json) | |
BASE_COMMIT=$(git merge-base HEAD origin/main) | |
PREVIOUS_VERSION="" | |
echo "Current version is $CURRENT_VERSION." | |
for commit in $(git rev-list $BASE_COMMIT..HEAD); do | |
VERSION=$(git show $commit:app/package.json | jq -r '.version') | |
echo "In a previous commit, the version was $VERSION." | |
if [ "$VERSION" != "$CURRENT_VERSION" ]; then | |
echo "Previous version is $PREVIOUS_VERSION." | |
PREVIOUS_VERSION=$VERSION | |
break | |
fi | |
done | |
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
echo "previous_version=$PREVIOUS_VERSION" >> $GITHUB_OUTPUT | |
if [ -n "$PREVIOUS_VERSION" ]; then | |
echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION." | |
else | |
echo "Version did not change." | |
fi | |
release: | |
runs-on: ubuntu-latest | |
needs: check-version | |
if: needs.check-version.outputs.previous_version != '' | |
steps: | |
- name: Release | |
run: | | |
echo "TODO: Make a release as version `${{ needs.check-version.outputs.current_version }}`." |