chroe: added comment to test release workflow #8
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: Publish and Release | |
on: | |
push: | |
branches: | |
- master | |
- release | |
paths: | |
- 'src/**' | |
- 'package.json' | |
- 'tsconfig.json' | |
- 'rollup.config.js' | |
- 'yarn.lock' | |
jobs: | |
lint: | |
name: Lint Code | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install --legacy-peer-deps | |
- name: Run ESLint | |
run: npx eslint 'src/**/*.ts' | |
- name: Run Prettier | |
run: npx prettier --check 'src/**/*.ts' | |
build: | |
name: Build Project | |
runs-on: ubuntu-latest | |
needs: lint | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm install --legacy-peer-deps | |
- name: Build project | |
run: npm run build | |
publish: | |
name: Publish and Release | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Install dependencies | |
run: npm install --legacy-peer-deps | |
- name: Stage changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "chore: prepare release" | |
- name: Bump version and create Git tag for release branch | |
if: github.ref == 'refs/heads/release' | |
id: bump_version_rc | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
npm version prerelease --preid=rc -m "chore(release): bump version to %s" | |
git push --follow-tags | |
- name: Bump version and create Git tag for master branch | |
if: github.ref == 'refs/heads/master' | |
id: bump_version_master | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add -A | |
# Remove the -rc tag from the version | |
current_version=$(node -p "require('./package.json').version") | |
new_version=$(echo $current_version | sed 's/-rc.*//') | |
echo "Current version: $current_version" | |
echo "New version: $new_version" | |
npm version $new_version -m "chore(release): bump version to %s" | |
git push --follow-tags | |
- name: Publish to npm (RC) | |
if: github.ref == 'refs/heads/release' | |
run: npm publish --tag rc | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish to npm (Stable) | |
if: github.ref == 'refs/heads/master' | |
run: npm publish --tag latest | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create GitHub Release | |
if: github.ref == 'refs/heads/release' || github.ref == 'refs/heads/master' | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.bump_version_rc.outputs.new_tag || steps.bump_version_master.outputs.new_tag }} | |
release_name: Release ${{ steps.bump_version_rc.outputs.new_tag || steps.bump_version_master.outputs.new_tag }} | |
draft: false | |
prerelease: ${{ github.ref == 'refs/heads/release' }} | |
- name: Upload Release Asset | |
if: github.ref == 'refs/heads/release' || github.ref == 'refs/heads/master' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist | |
asset_name: dist | |
asset_content_type: application/zip |