Build and upload artifact #9
This file contains hidden or 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 upload artifact | |
| on: | |
| push: | |
| tags: | |
| - v* | |
| workflow_dispatch: | |
| jobs: | |
| build-package: | |
| name: Build and export package | |
| runs-on: ubuntu-latest | |
| steps: | |
| #Checkout | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: true | |
| # Read package name and version from package.json | |
| - name: Get package name and version | |
| id: pkg | |
| run: | | |
| PKG_NAME=$(jq -r '.name' ./package.json) | |
| PKG_VERSION=$(jq -r '.version' ./package.json) | |
| PKG_FILENAME="$(basename $PKG_NAME)-$PKG_VERSION.tgz" | |
| echo "pkg_name=$PKG_NAME" >> $GITHUB_OUTPUT | |
| echo "pkg_version=$PKG_VERSION" >> $GITHUB_OUTPUT | |
| echo "pkg_filename=$PKG_FILENAME" >> $GITHUB_OUTPUT | |
| # Create .tgz tarball of the package folder | |
| - name: Pack UPM package | |
| run: | | |
| tar -czf "${{ steps.pkg.outputs.pkg_filename }}" * | |
| - name: Generate release notes | |
| run: | | |
| echo "🎉 New release of ${{ steps.pkg.outputs.pkg_name }}" > RELEASE_NOTES.md | |
| echo "Version: ${{ steps.pkg.outputs.pkg_version }}" >> RELEASE_NOTES.md | |
| echo "" >> RELEASE_NOTES.md | |
| echo "## Changelog" >> RELEASE_NOTES.md | |
| echo "- Feature A" >> RELEASE_NOTES.md | |
| echo "- Fix B" >> RELEASE_NOTES.md | |
| - name: Upload release asset | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ steps.pkg.outputs.pkg_name }}-v${{ steps.pkg.outputs.pkg_version }} | |
| path: ${{ steps.pkg.outputs.pkg_filename }} | |
| - name: Upload release notes | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-notes-v${{ steps.pkg.outputs.pkg_version }} | |
| path: RELEASE_NOTES.md | |
| - name: Create local tag | |
| run: | | |
| git tag v${{ steps.pkg.outputs.pkg_version }} |