Skip to content

Commit

Permalink
ci: package workflow now adds the package as asset
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsergio committed May 6, 2024
1 parent 5444873 commit a3619fe
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ jobs:
run: |
npm install && npm run compile && npm prune --production && vsce package
- name: debug
run: env
- name: Upload asset
run: |
sh upload_package.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions upload_package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Sergio Martins <sergio.martins@kdab.com>
# SPDX-License-Identifier: MIT

# Uploads the qttests-<version>.vsix package to GitHub Release
# Called by .github/workflows/package.yml

# Get latest tag:
TAG_NAME=`git describe --tags --abbrev=0`

# Drop the 'v' prefix:
VERSION=${TAG_NAME:1}

PACKAGE_FILENAME=qttests-$VERSION.vsix

if [ ! -f $PACKAGE_FILENAME ]; then
# Doesn't happen. Package is created by package.yml
echo "Package $PACKAGE_FILENAME does not exist"
exit 1
fi

# Check if release exists:
gh release view $TAG_NAME &> /dev/null
if [ $? -ne 0 ]; then
# Should not happen, as releases are created by release-please
echo "Release $TAG_NAME does not exist"
exit 1
fi

# Check if release already contains the asset:
gh release view $TAG_NAME --json assets | jq -r '.assets[].name' | grep -q $PACKAGE_FILENAME

if [ $? -eq 0 ]; then
echo "Asset $PACKAGE_FILENAME already exists in release $TAG_NAME"
exit 0
fi

gh release upload $TAG_NAME $PACKAGE_FILENAME

0 comments on commit a3619fe

Please sign in to comment.