diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4777f1c..7ca85b5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,6 @@ on: env: CARGO_TERM_COLOR: always - VSCE_PAT: ${{ secrets.VSCE_ACCESS_TOKEN }} jobs: publish-prerelease: @@ -30,8 +29,19 @@ jobs: - name: Try bump kanata run: | - just bump_kanata - git push + status=$(just bump_kanata; echo $?) + if [ $status -eq 0 ]; then + git push + elif [ $status -eq 123 ]; then + # Status 123 means that the version of kanata is already most recent. + # Ideally, we'd like to the workflow to appear as canceled. + gh run cancel ${{ github.run_id }} + gh run watch ${{ github.run_id }} + else + echo "Failed with $status" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Setup - cargo cache uses: actions/cache@v3 @@ -73,3 +83,5 @@ jobs: - name: Build and publish run: just pre_release ${{ steps.new-version.outputs.value }} + env: + VSCE_PAT: ${{ secrets.VSCE_ACCESS_TOKEN }} diff --git a/justfile b/justfile index ccf2110..175c0f6 100644 --- a/justfile +++ b/justfile @@ -14,8 +14,10 @@ bump_kanata: cd kanata HASH=$(git rev-parse --short HEAD) cd .. - # Exit early without updating changelog if a bump notice was already added in "Unreleased" section. - $(! grep -q "$HASH" CHANGELOG.md) + # Exit early without updating changelog if a bump notice has already been added in "Unreleased" section. + # This works because of a some weird behavior of bash. More about it here: + # http://redsymbol.net/articles/unofficial-bash-strict-mode/#short-circuiting + grep -q "$HASH" CHANGELOG.md && (exit 123) awk '/^### [0-9]/ && found==0 {found=1} found==0 && /Updated kanata to/ {next} 1' CHANGELOG.md > temp && mv temp CHANGELOG.md just _add_to_changelog "Updated kanata to \[$HASH\]\(https\:\/\/github\.com\/jtroo\/kanata\/tree\/$HASH\)" just _ensure_no_staged_changes