update #6
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: Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Set up Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
# # Authenticate with GitHub Packages | |
# - name: Authenticate with GitHub Packages | |
# run: | | |
# echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Install dependencies | |
- name: Install dependencies | |
run: yarn install | |
- name: Run tests | |
run: yarn test | |
# Build the package | |
- name: Build the package | |
run: yarn build | |
# # Publish the package to GitHub Packages | |
# - name: Publish to GitHub Packages | |
# run: yarn publish --access public --verbose # Or use 'restricted' for private packages | |
# - name: Zip build files | |
# run: zip -r build.zip ./dist # Change ./dist to your build directory | |
- name: Compress build files to tar.gz | |
run: tar -czvf build.tar.gz ./dist package.json README.md LICENSE # Change ./dist to your build directory | |
- name: Get version from package.json | |
id: get_version | |
run: | | |
VERSION=$(jq -r .version package.json) | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Create tag | |
env: | |
VERSION: ${{ env.VERSION }} | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git tag -a "v$VERSION" -m "Release version $VERSION" | |
git push origin "v$VERSION" | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: "v${{ env.VERSION }}" | |
release_name: "Release v${{ env.VERSION }}" | |
draft: false | |
prerelease: false | |
- name: Upload build artifact to release | |
uses: actions/upload-release-asset@v2 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./build.tar.gz | |
asset_name: build.tar.gz | |
asset_content_type: application/gzip |