Skip to content

Update publish-release.yml #4

Update publish-release.yml

Update publish-release.yml #4

name: Publish Release
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: write
issues: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Build project
run: |
npm ci
npm run build
- name: Zip bundle
run: |
zip -r ./${{ github.sha }}.zip .
- name: Archive artifact
uses: actions/upload-artifact@v3
with:
name: zipped-bundle
path: ${{ github.sha }}.zip
publish:
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Get version from package.json
id: get_version
run: |
VERSION=$(jq -r .version < package.json)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
body: New release for commit ${{ github.sha }}.
draft: true
prerelease: true
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: zipped-bundle
- 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: ./${{ github.sha }}.zip
asset_name: source_code_with_libraries.zip
asset_content_type: application/zip