v0.1.0-pre5 #36
Workflow file for this run
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 Release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'リリース対象のタグ (例: v0.1.0) - 指定タグのコードをビルドします' | |
| required: true | |
| type: string | |
| push: | |
| tags: | |
| - "v[0-9]+\\.[0-9]+\\.[0-9]+" | |
| - "v[0-9]+\\.[0-9]+\\.[0-9]+-[a-zA-Z0-9]+" | |
| env: | |
| packageName: "taremin.copy-components-by-regex" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| ref: ${{ inputs.tag || github.ref }} | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: version | |
| id: version | |
| run: | | |
| REPOSITORY=$(echo ${{ github.event.repository.name }}) | |
| echo repository=$REPOSITORY >> $GITHUB_OUTPUT | |
| # 手動実行時はinputs.tagを使用、タグプッシュ時はgithub.refを使用 | |
| if [ -n "${{ inputs.tag }}" ]; then | |
| VERSION="${{ inputs.tag }}" | |
| else | |
| VERSION=$(basename ${{ github.ref }}) | |
| fi | |
| echo version=$VERSION >> $GITHUB_OUTPUT | |
| ARCHIVE_BASENAME=$(echo $REPOSITORY-$VERSION) | |
| echo basename=$ARCHIVE_BASENAME >> $GITHUB_OUTPUT | |
| ZIP_FILENAME=$(echo $ARCHIVE_BASENAME.zip) | |
| echo zip=$ZIP_FILENAME >> $GITHUB_OUTPUT | |
| PACKAGE_FILENAME=$(echo $ARCHIVE_BASENAME.unitypackage) | |
| echo unitypackage=$PACKAGE_FILENAME >> $GITHUB_OUTPUT | |
| - name: Determine Previous Release Tag | |
| id: release_info | |
| run: | | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [[ "$VERSION" == *"-"* ]]; then | |
| # プレリリース: 直前のタグを使用 | |
| PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") | |
| else | |
| # 正式リリース: 現在のタグを除外した最新の正式バージョンを取得 | |
| PREVIOUS_TAG=$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | grep -v '-' | grep -v "^${VERSION}$" | head -1) | |
| fi | |
| echo "previous_tag=$PREVIOUS_TAG" >> $GITHUB_OUTPUT | |
| echo "前のタグ: $PREVIOUS_TAG" | |
| - name: Generate Changelog | |
| id: changelog | |
| run: | | |
| PREVIOUS_TAG="${{ steps.release_info.outputs.previous_tag }}" | |
| VERSION="${{ steps.version.outputs.version }}" | |
| if [ -n "$PREVIOUS_TAG" ]; then | |
| echo "## 変更内容 (${PREVIOUS_TAG}...${VERSION})" > changelog.md | |
| echo "" >> changelog.md | |
| git log --pretty=format:"- %s (%h)" ${PREVIOUS_TAG}..HEAD >> changelog.md | |
| else | |
| echo "## 変更内容" > changelog.md | |
| echo "" >> changelog.md | |
| git log --pretty=format:"- %s (%h)" >> changelog.md | |
| fi | |
| # ランダムなデリミタを生成してEOF衝突を回避 | |
| DELIMITER="CHANGELOG_$(date +%s%N)" | |
| echo "changelog<<${DELIMITER}" >> $GITHUB_OUTPUT | |
| cat changelog.md >> $GITHUB_OUTPUT | |
| echo "" >> $GITHUB_OUTPUT | |
| echo "${DELIMITER}" >> $GITHUB_OUTPUT | |
| - name: Create Zip | |
| uses: thedoctor0/zip-release@09336613be18a8208dfa66bd57efafd9e2685657 | |
| with: | |
| type: "zip" | |
| filename: "${{ steps.version.outputs.zip }}" | |
| exclusions: '*.git*' | |
| - name: Check Zip | |
| run: ls -al ${{ steps.version.outputs.zip }} | |
| - name: Create UnityPackage Directory | |
| run: mkdir -p "Assets/${{ github.repository_owner }}/${{ github.event.repository.name }}" | |
| - name: Move to Unitypackage Directory | |
| run: find . -mindepth 1 -maxdepth 1 -regextype egrep -not \( -name Assets -o -name '*.zip' \) -exec mv -t "Assets/${{ github.repository_owner }}/${{ github.event.repository.name }}" {} + | |
| - name: Create .meta list | |
| run: find "Assets/" -name "*.meta" >> metaList | |
| - name: Check .meta list | |
| run: cat metaList | |
| - name: Create UnityPackage | |
| uses: pCYSl5EDgo/create-unitypackage@v1.2.3 | |
| with: | |
| package-path: ${{ steps.version.outputs.unitypackage }} | |
| include-files: metaList | |
| - name: Make Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ inputs.tag || github.ref_name }} | |
| name: CopyComponentsByRegex ${{ steps.version.outputs.version }} | |
| body: ${{ steps.changelog.outputs.changelog }} | |
| draft: true | |
| prerelease: ${{ contains(steps.version.outputs.version, '-') }} | |
| files: | | |
| ${{ steps.version.outputs.zip }} | |
| ${{ steps.version.outputs.unitypackage }} | |
| "Assets/${{ github.repository_owner }}/${{ github.event.repository.name }}/package.json" |