Merge pull request #109 from deimosowen/release-1.9 #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: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '18.x' | |
- run: npm install | |
# Run build script which includes version bump | |
- run: npm run build | |
# Extract the updated version number from package.json | |
- name: Set version as env | |
run: echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV | |
# Tag the new version | |
- name: Create tag | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git tag v${{ env.VERSION }} | |
git push origin v${{ env.VERSION }} | |
# Archive the production artifacts | |
- name: Archive production artifacts | |
run: | | |
cd dist | |
zip -r ../dist.zip . | |
# Create a release with the new tag | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.VERSION }} | |
release_name: Release v${{ env.VERSION }} | |
draft: false | |
prerelease: false | |
# Upload the release asset | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./dist.zip | |
asset_name: dist.zip | |
asset_content_type: application/zip |