fix release workflow #10
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: Release | |
on: | |
push: | |
branches: [main] | |
env: | |
GH_TOKEN: ${{ github.token }} | |
jobs: | |
Release: | |
name: Release | |
permissions: write-all | |
runs-on: [ubuntu-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- id: get-version | |
name: Get Version | |
run: | | |
unset version | |
version=$(./sver version) | |
echo "Validating ${version}" | |
./sver version <<< "$version" | |
echo "version=${version}" >> "$GITHUB_OUTPUT" | |
echo "major=$(./sver get major "$version")" >> "$GITHUB_OUTPUT" | |
echo "minor=$(./sver get minor "$version")" >> "$GITHUB_OUTPUT" | |
- id: is-existing-release | |
name: Checking if Release Exists | |
run: | | |
unset version_already_exists | |
if [ "$( | |
gh release list \ | |
--json tagName \ | |
--jq ' | |
.[] | | |
select(.tagName == "${{ steps.get-version.outputs.version }}") | | |
length > 0 | |
' | |
)" = true ] ; then | |
echo 'exists=true' >> "$GITHUB_OUTPUT" | |
else | |
echo 'exists=false' >> "$GITHUB_OUTPUT" | |
fi | |
- if: steps.is-existing-release.outputs.exists == 'false' | |
name: Create New Release | |
run: | | |
gh release \ | |
create "v${{ steps.get-version.outputs.version }}" \ | |
--generate-notes \ | |
--latest \ | |
sver | |
git tag -f 'v${{ steps.get-version.outputs.major }}' | |
git tag -f 'v${{ steps.get-version.outputs.major }}.${{ steps.get-version.outputs.minor }}' | |
git push -f --tags |