Skip to content

Commit

Permalink
chore: move latest tag upon releasing new versions (#24)
Browse files Browse the repository at this point in the history
* chore: move "latest" tag upon releasing new versions

* format

* comment

* simplify git delete tag operation
  • Loading branch information
sripwoud authored May 7, 2024
1 parent 89c9143 commit 2ca6675
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ jobs:
run: npm i

- name: Release
id: changesets
uses: changesets/action@v1
with:
publish: npm exec changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Update 'latest' tag for published packages
# https://github.com/changesets/action?tab=readme-ov-file#outputs
run: ./scripts/bin/move-latest-tag ${{ steps.changesets.outputs.publishedPackages }} ${{ github.sha }}
28 changes: 28 additions & 0 deletions scripts/bin/move-latest-tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -euo pipefail

move_tag() {
local package="$1"
local commit_sha="$2"
local tag="$package@latest"

git push -d origin "$tag"
git tag "$tag" "$commit_sha"
git push origin "$tag"
}

get_package_names() {
jq -r '.[].name' "$1"
}

main() {
local published_packages="$1"
local commit_sha="$2"

while IFS= read -r package; do
move_tag "$package" "$commit_sha"
done < <(get_package_names "$published_packages")
}

main "$@"

0 comments on commit 2ca6675

Please sign in to comment.