Skip to content

Publish Release

Publish Release #11

name: Publish Release
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: write
issues: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract-version.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: extract package version
id: extract-version
run: |
VERSION=$(jq -r .version < package.json)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- 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: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
with:
tag_name: ${{ needs.build.outputs.version }}
release_name: Release ${{ needs.build.outputs.version }}
body: New release for commit ${{ github.sha }}.
draft: false
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