Skip to content

Commit

Permalink
chore: idempotent npm release and fix for git tag determination (#4232)
Browse files Browse the repository at this point in the history
- If a version is already published, will skip it instead of failing
- Use the latest version of git tag based on semver sort rather than date. This previously failed if a commit had more than one tag

*By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
MarkMcCulloh authored Sep 20, 2023
1 parent c1e7360 commit 24114df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,19 @@ jobs:
env:
PACKAGE_VERSION: ${{ needs.build.outputs.version }}
run: |
PACKAGES=("winglang-sdk" "winglang-compiler" "wingconsole-design-system" "wingconsole-ui" "wingconsole-server" "wingconsole-app" "winglang")
PACKAGES=("@winglang/sdk" "@winglang/compiler" "@wingconsole/design-system" "@wingconsole/ui" "@wingconsole/server" "@wingconsole/app" "winglang")
for PACKAGE in "${PACKAGES[@]}"; do
npm publish "$PACKAGE-$PACKAGE_VERSION.tgz" --access public
# Check if already published
VERSION_FOUND=$(npm view "$PACKAGE@$PACKAGE_VERSION" version 2> /dev/null)
if [ "$VERSION_FOUND" = "$PACKAGE_VERSION" ]; then
echo "$PACKAGE@$PACKAGE_VERSION already published, skipping"
continue
fi
# remove "@" and replace "/" with "-"
TARBALL=$(echo "$PACKAGE-$PACKAGE_VERSION.tgz" | sed 's/@//g' | sed 's/\//-/g')
npm publish "$TARBALL" --access public
done
- name: Publish Extension to Visual Studio Marketplace
Expand Down
2 changes: 1 addition & 1 deletion tools/bump-pack/src/release-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function getReleaseData() {
},
});

const lastTag = execSync("git tag --sort=committerdate | tail -1", {
const lastTag = execSync("git tag -l --sort=version:refname | tail -1", {
encoding: "utf8",
}).trim();
const lastVersion = lastTag.replace("v", "");
Expand Down

0 comments on commit 24114df

Please sign in to comment.