v0.5.0 #80
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
name: 'generate' | |
on: | |
push: | |
branches: | |
- 'main' | |
env: | |
YARN_COMPRESSION_LEVEL: 0 | |
YARN_ENABLE_GLOBAL_CACHE: true | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Calculate major version | |
run: | | |
# Get version from package.json (head is needed because this also returns "version" npm script line) | |
sed -n '/version/s/,*\r*$//p' package.json | cut -d ':' -f2,3 | sed -e 's/^ "//' -e 's/"$//' | head -n 1 > app_version.tmp | |
cat app_version.tmp | cut -d. -f1 > major_version.tmp | |
export VERSION_TAG="v$(cat app_version.tmp)" | |
echo "package_version=$(cat app_version.tmp)" >> $GITHUB_ENV | |
echo "major_version=$(cat major_version.tmp)" >> $GITHUB_ENV | |
# Check if tag already exists | |
if [ $(git tag -l "$VERSION_TAG") ]; then | |
echo "Tag already exists, please increment version to create release" | |
echo "create_release=no" >> $GITHUB_ENV | |
else | |
echo "create_release=yes" >> $GITHUB_ENV | |
fi | |
- name: Use Node.js 16 | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
cache: 'yarn' | |
- name: 📦 Install dependencies | |
run: yarn install --immutable | |
- name: 🔨 Build Project | |
run: yarn package | |
- name: Checkout release branch | |
uses: actions/checkout@v2 | |
with: | |
path: release | |
ref: releases/v${{ env.major_version }} | |
token: ${{ secrets.DRONE_USER_TOKEN }} | |
- name: Copy to release branch | |
run: | | |
# Copy build | |
cp -r dist release | |
cp package.json release/ | |
cp yarn.lock release/ | |
cp -r .yarn release/ | |
cp action.yml release/ | |
# Copy pipelines | |
cp -r .github release | |
cp .gitlab-ci.yml release/ | |
cp .drone.yml release/ | |
cp -r docs release | |
cp README.md release/ | |
cp LICENSE release/ | |
# Add executables | |
cp -r bin release | |
# Copy release dockerfile as main dockerfile | |
cp Dockerfile.release release/Dockerfile | |
# Add all gitignore except dist folder | |
head -n -4 .gitignore > release/.gitignore | |
- name: Commit and push to release branch | |
working-directory: release | |
if: ${{ env.create_release == 'yes' }} | |
run: | | |
git config user.name rohit-drone | |
git config user.email [email protected] | |
git add -A . | |
git commit -m "Release ${{ env.package_version }}, generated from commit ${{ github.sha }}" | |
git push | |
- name: Commit and push to release branch - Alpha | |
working-directory: release | |
if: ${{ env.create_release == 'no' }} | |
run: | | |
git config user.name rohit-drone | |
git config user.email [email protected] | |
git add -A . | |
git commit -m "Alpha version, generated from commit ${{ github.sha }}" | |
git push |