diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 6657f43..be85fb8 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,41 +14,43 @@ jobs: 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" + echo 'json<>"${GITHUB_OUTPUT}" + ./sver json "$(./sver version)" | \ + tee -a "$GITHUB_OUTPUT" | \ + jq -C + echo EOF >>"${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" + if [ -n "$( + gh release list \ + --json tagName \ + --jq '.[] | .tagName' | \ + ./sver filter '${{ fromJSON(steps.get-version.outputs.json).version }}' + )" ] ; then + echo exists=true >> "$GITHUB_OUTPUT" else - echo 'exists=false' >> "$GITHUB_OUTPUT" - fi - - if: steps.is-existing-release.outputs.exists == 'false' + echo exists=false >> "$GITHUB_OUTPUT" + fi + + - env: + MAJOR: ${{ fromJSON(steps.get-version.outputs.json).major }} + MINOR: ${{ fromJSON(steps.get-version.outputs.json).minor }} + VERSION: v${{ fromJSON(steps.get-version.outputs.json).version }} + if: steps.is-existing-release.outputs.exists == 'false' name: Create New Release run: | gh release \ - create "${{ steps.get-version.outputs.version }}" \ + create "$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 }}' + gh release upload "$VERSION" ./sver + git tag -f "v${MAJOR}" + git tag -f "v${MAJOR}.${MINOR}" git push -f --tags diff --git a/README.md b/README.md index b2863d9..9c2c572 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ asdf global sver latest #### curl You can simply curl a version directly. ```bash -curl -LO https://github.com/robzr/sver/releases/download/v1.2.0/sver +curl -LO https://github.com/robzr/sver/releases/download/v1.2.1/sver ``` #### Homebrew @@ -63,11 +63,11 @@ Command completion is available for Bash users. Simply add the following to your ### Command line usage See `sver help` for documentation. ```text -sver v1.2.0 (https://github.com/robzr/sver) self contained cli tool and function +sver v1.2.1 (https://github.com/robzr/sver) self contained cli tool and function library implementing a Semantic Versioning 2 compliant parser and utilities. Written in optimized, portable, pure Bash (v3)+ for simplicity & speed. -Usage: sver [] [|