chore: Update dependencies (#2944) #949
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright (c) 2019-2023 Red Hat, Inc. | |
# This program and the accompanying materials are made | |
# available under the terms of the Eclipse Public License 2.0 | |
# which is available at https://www.eclipse.org/legal/epl-2.0/ | |
# | |
# SPDX-License-Identifier: EPL-2.0 | |
# | |
# Contributors: | |
# Red Hat, Inc. - initial API and implementation | |
# | |
name: Release - generate release and push artifacts to github pages (after PR approved) | |
on: | |
# Trigger the workflow on push only for the main and 7.y.x branches | |
push: | |
branches: | |
- '7.*.x' | |
- 'main' | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
persist-credentials: false | |
- name: Install NodeJS | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.18.0 | |
- name: Compute tags and SHAs | |
id: TAG_SHA | |
run: | | |
SHORT_SHA1=$(git rev-parse --short HEAD) | |
echo "short_sha1=$SHORT_SHA1" >> $GITHUB_OUTPUT | |
if [[ ${GITHUB_REF#refs/heads/} =~ 7.* ]]; then | |
echo "chectl_version=$(cat VERSION)" >> $GITHUB_OUTPUT | |
echo "gh_release_name=$(cat VERSION)" >> $GITHUB_OUTPUT | |
echo "gh_tag=$(cat VERSION)" >> $GITHUB_OUTPUT | |
elif [[ ${GITHUB_REF#refs/heads/} =~ main ]]; then | |
CURRENT_DAY=$(date +'%Y%m%d') | |
echo "gh_tag=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT | |
echo "chectl_version=0.0.$CURRENT_DAY-next.$SHORT_SHA1" >> $GITHUB_OUTPUT | |
echo "gh_release_name=0.0.$CURRENT_DAY-next.$SHORT_SHA1" >> $GITHUB_OUTPUT | |
fi | |
- name: Build chectl | |
run: yarn | |
- name: Run unit tests | |
run: yarn test | |
- name: Pack chectl | |
run: | | |
git config --local user.name ${{ github.actor }} | |
sed -i "0,/\"version\":\ \"\(.*\)\",/s/\"version\":\ \"\(.*\)\",/\"version\":\ \"${{ steps.TAG_SHA.outputs.chectl_version }}\",/" package.json | |
sed -i "s|INSERT-KEY-HERE|${{ secrets.SEGMENT_WRITE_KEY }}|g" src/hooks/analytics/analytics.ts | |
git tag ${{ steps.TAG_SHA.outputs.gh_tag }} | |
TARGETS=linux-arm,linux-x64,linux-s390x,linux-ppc64le,darwin-x64,darwin-arm64,win32-x64,win32-x86 | |
yarn prepack && yarn pack-binaries --targets=$TARGETS | |
# Rename binaries to remove the sha1 from their names | |
for file in ./dist/*; do | |
mv "$file" "${file/-v${{ steps.TAG_SHA.outputs.chectl_version }}-${{ steps.TAG_SHA.outputs.short_sha1 }}/}" | |
done | |
- name: Create Release and push artifacts | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: ${{ steps.TAG_SHA.outputs.gh_release_name }} | |
tag_name: ${{ steps.TAG_SHA.outputs.gh_tag }} | |
files: "./dist/chectl-*.gz" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Update github pages | |
run: | | |
git clone https://github.com/che-incubator/chectl -b gh-pages --single-branch gh-pages | |
rm -rf gh-pages/.git | |
echo $(date +%s) > gh-pages/update | |
env | |
- name: Deploy to github pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BRANCH: gh-pages | |
FOLDER: gh-pages | |
CLEAN: true # Automatically remove deleted files from the deploy branch |