update rainlang package version [pre-release] #27
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: Standard Publish | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
# do not start if [skip-publish] and [skip publish] is found in commit msg | |
# configuration: | |
# - you can change the keywords to your desired ones in the below "if" statement | |
if: contains(github.event.head_commit.message, '[skip-publish]') != true && contains(github.event.head_commit.message, '[skip publish]') != true | |
# All steps of the job depend on their previous step to finish successfully | |
steps: | |
# Checkout repo | |
- name: Checkout Repo | |
id: checkout | |
uses: actions/checkout@v3 | |
# Install node | |
- name: Install NodeJS v18 | |
id: node | |
if: steps.checkout.outcome == 'success' | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
# Install deps | |
- name: Install Dependencies | |
id: install | |
if: steps.node.outcome == 'success' | |
run: npm install | |
# Build the prod package | |
- name: Build | |
id: build | |
if: steps.install.outcome == 'success' | |
run: npm run build-prod | |
# Lint the source code | |
- name: Lint | |
id: lint | |
if: steps.build.outcome == 'success' | |
run: npm run lint | |
# install playwright | |
- name: Install Playwright | |
id: playwright | |
if: steps.lint.outcome == 'success' | |
run: npx playwright install | |
# Run the tests | |
- name: Test | |
id: test | |
if: steps.playwright.outcome == 'success' | |
# needs headless setup | |
uses: coactions/setup-xvfb@v1 | |
with: | |
run: npm test | |
# Configure Git | |
- name: Git Config | |
id: git | |
if: steps.test.outcome == 'success' | |
# set git user and email to github actions, | |
# this email and user id will result in github user with github avatar in Github | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "GitHub Actions" | |
# Major Release | |
- name: Bump Major Version | |
id: major | |
# bump major version only if the commit msg ends with [major] keyword | |
# [major] keyword must be at the end of commit msg | |
# configuration: | |
# - you can change the keyword to your desired one in the below "if" statement | |
if: steps.git.outcome == 'success' && endsWith(github.event.head_commit.message, '[major]') | |
# bump the major version without creating tag and commit and store the version in env | |
run: echo "NEW_VERSION=$(npm version major --no-git-tag-version)" >> $GITHUB_ENV | |
# Minor Release | |
- name: Bump Minor Version | |
id: minor | |
# bump minor version only if the commit msg ends with [minor] keyword | |
# [minor] keyword must be at the end of commit msg | |
# configuration: | |
# - you can change the keyword to your desired one in the below "if" statement | |
if: steps.git.outcome == 'success' && endsWith(github.event.head_commit.message, '[minor]') | |
# bump the minor version without creating tag and commit and store the version in env | |
run: echo "NEW_VERSION=$(npm version minor --no-git-tag-version)" >> $GITHUB_ENV | |
# Patch Release | |
- name: Bump Patch Version | |
id: patch | |
# bump patch version only if [major] and [minor] are not present in commit msg | |
# will increase patch version for any other commits that don't have major and minor keywords | |
# configuration: | |
# - alternatively you can set a keyword for bumping patch version with specific keyword | |
if: steps.git.outcome == 'success' && ! endsWith(github.event.head_commit.message, '[major]') && ! endsWith(github.event.head_commit.message, '[minor]') | |
# bump the patch version without creating tag and commit and store the version in env | |
run: echo "NEW_VERSION=$(npm version patch --no-git-tag-version)" >> $GITHUB_ENV | |
# Commit changes and tag | |
- name: Commit And Tag | |
id: commit | |
if: steps.major.outcome == 'success' || steps.minor.outcome == 'success' || steps.patch.outcome == 'success' | |
run: | | |
git add "package.json" | |
git add "package-lock.json" | |
git commit -m "Release ${{ env.NEW_VERSION }}" | |
git tag ${{ env.NEW_VERSION }} | |
# Push changes and tag | |
- name: Push Changes To Remote | |
id: push | |
if: steps.commit.outcome == 'success' | |
run: | | |
git push origin | |
git push -u origin ${{ env.NEW_VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Create gitHub release with built package archives | |
- name: Create GitHub Release | |
id: release | |
if: steps.push.outcome == 'success' | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.NEW_VERSION }} | |
name: Release ${{ env.NEW_VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Publish an official version to vscode marketplace | |
- name: Official Publish To vscode Marketplace | |
if: steps.release.outcome == 'success' && contains(github.event.head_commit.message, '[pre-release]') != true | |
run: y | npx vsce publish | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
# Publish a pre-release version to vscode marketplace | |
- name: Pre-release Publish To vscode Marketplace | |
if: steps.release.outcome == 'success' && contains(github.event.head_commit.message, '[pre-release]') | |
run: y | npx vsce publish --pre-release | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} |