Skip to content

Set version to 2025.09.23 (#494) #458

Set version to 2025.09.23 (#494)

Set version to 2025.09.23 (#494) #458

Workflow file for this run

name: QWC2 Build
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Use Node.js
uses: actions/[email protected]
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install all required dependencies
run: |
yarn install
sudo apt-get update
sudo apt-get -y install jq
- name: Check package version
run: |
if [ ${{ startsWith(github.ref, 'refs/tags/') }} = true ]; then
VERSION=$(basename ${{ github.ref }})
if [[ $VERSION == *-lts ]]; then
VERSION=$(echo $VERSION | sed -E 's|v([0-9]+).([0-9]+)-lts|v\1.0.\2-lts|')
fi
# Abort if version is not the same as in package.json
PKGVERSION=$(jq -r '.version' package.json)
if [ "$VERSION" != "v$PKGVERSION" ]; then
echo "Version mismatch: tag is ${VERSION}, package.json version is ${PKGVERSION}"
exit 1
fi
fi
- name: Compile a deployable application bundle
run: yarn run prod
- name: Create zip
run: zip -r qwc2-stock-app.zip prod/
- name: Version number
id: version_number
run: |
if [ ${{ startsWith(github.ref, 'refs/tags/') }} = true ]; then
VERSION=$(basename ${{ github.ref }})
else
VERSION=ci-latest-$(basename ${{ github.ref }})
PREV_RELEASE=$(curl -s https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/$VERSION | jq -r .url)
# Reset ci-latest tag
git config --global user.email "[email protected]"
git config --global user.name "Github CI"
# Workaround for "could not read Username for 'https://github.com': No such device or address"
git remote set-url origin https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git
git tag -d $VERSION || true
git push origin :$VERSION || true
git tag -m $VERSION $VERSION
git push --tags
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "prev_release=${PREV_RELEASE/null/}" >> $GITHUB_OUTPUT
env:
# This token is provided by Actions, you do not need to create your own token.
# The token is only valid for one hour.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version_number.outputs.version }}
release_name: ${{ steps.version_number.outputs.version }}
draft: false
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }}
- name: Upload release asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./qwc2-stock-app.zip
asset_name: qwc2-stock-app.zip
asset_content_type: application/zip
- name: Delete previous release
run: |
curl -s -H "authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-X DELETE ${{ steps.version_number.outputs.prev_release }}
if: steps.version_number.outputs.prev_release != ''
- name: Publish to NPM
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
run: |
npm run dist
pushd dist
npm publish
popd
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}