modular-avatar/.github/workflows/build-release.yml

92 lines
2.9 KiB
YAML
Raw Normal View History

2022-09-08 11:46:13 +08:00
name: Build Release
2022-08-29 11:16:02 +08:00
2022-09-08 11:46:13 +08:00
on:
workflow_dispatch:
2022-09-09 11:52:06 +08:00
pull_request:
2022-09-08 11:46:13 +08:00
push:
2022-09-09 11:37:40 +08:00
branches:
- main
- refactor-structure
2022-09-09 11:37:40 +08:00
tags:
- '**'
2022-09-08 11:46:13 +08:00
env:
2022-11-11 12:39:58 +08:00
packageName: "nadena.dev.modular-avatar"
2022-08-29 11:16:02 +08:00
jobs:
2022-09-08 11:46:13 +08:00
build:
2022-08-29 11:16:02 +08:00
runs-on: ubuntu-latest
steps:
2022-09-08 11:46:13 +08:00
- name: Checkout
uses: actions/checkout@v4
2022-10-23 04:31:10 +08:00
- name: Checkout logo assets
uses: actions/checkout@v4
2022-10-23 04:31:10 +08:00
if: startsWith(github.ref, 'refs/tags/')
with:
repository: bdunderscore/modular-avatar-images
path: .github/image-assets
2022-10-23 04:31:10 +08:00
- name: Inject logo assets
if: startsWith(github.ref, 'refs/tags/')
run: |
cp -f .github/image-assets/img/logo/ma_logo.png Editor/Images/logo.png
cp -f .github/image-assets/img/logo/ma_icon.png Runtime/Icons/Icon_MA_Script.png
2022-09-08 11:46:13 +08:00
- name: Check semver syntax
id: semver-check
if: startsWith(github.ref, 'refs/tags/')
env:
REF_NAME: ${{ github.ref }}
run: |
if echo $REF_NAME | grep '[a-z]-[0-9]' && ! echo $REF_NAME | grep '^refs/tags/1\.5\.0-'; then
echo "Tag name does not follow semver prerelease syntax: $REF_NAME"
exit 1
fi
2022-09-08 11:46:13 +08:00
- name: get version
2022-08-29 11:16:02 +08:00
id: version
uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8
2022-08-29 11:16:02 +08:00
with:
path: "package.json"
2022-09-08 11:46:13 +08:00
prop_path: "version"
2022-09-09 11:37:40 +08:00
- name: Check tag consistency
if: startsWith(github.ref, 'refs/tags/')
run: |
if [ "${{ steps.version.outputs.prop }}" != "${GITHUB_REF##*/}" ]; then
echo "Version in package.json does not match tag name: ${{ steps.version.outputs.prop }} != ${GITHUB_REF##*/}"
exit 1
fi
2022-09-08 11:46:13 +08:00
- run: echo ${{steps.version.outputs.prop}}
- name: Set Environment Variables
run: |
echo "zipFile=${{ env.packageName }}-${{ steps.version.outputs.prop }}".zip >> $GITHUB_ENV
2024-07-02 11:49:55 +08:00
echo "zipFileSHA256=${{ env.packageName }}-${{ steps.version.outputs.prop }}".zip.sha256 >> $GITHUB_ENV
2022-09-08 11:46:13 +08:00
echo "unityPackage=${{ env.packageName }}-${{ steps.version.outputs.prop }}.unitypackage" >> $GITHUB_ENV
- name: Create Zip
run: |
zip ".github/${{env.zipFile}}" ./* -r -x .github .git '.git/*' '*~/*' '*.ps1*'
mv ".github/${{env.zipFile}}" "${{env.zipFile}}"
2024-07-02 11:49:55 +08:00
sha256sum "${{env.zipFile}}" > "${{env.zipFileSHA256}}"
2022-09-08 11:46:13 +08:00
- uses: actions/upload-artifact@v4
with:
name: package-zip
path: ${{ env.zipFile }}
2022-09-08 11:46:13 +08:00
- name: Make Release
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191
2022-09-09 11:37:40 +08:00
if: startsWith(github.ref, 'refs/tags/')
2022-08-29 11:16:02 +08:00
with:
2022-09-09 11:37:40 +08:00
draft: true
generate_release_notes: true
2022-09-08 11:46:13 +08:00
tag_name: ${{ steps.version.outputs.prop }}
files: |
${{ env.zipFile }}
2024-07-02 11:49:55 +08:00
${{ env.zipFileSHA256 }}
package.json