diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index d222c1c..824d60e 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -2,7 +2,6 @@ name: Build Release on: workflow_dispatch: - pull_request: push: branches: - main @@ -12,33 +11,87 @@ on: env: packageName: "nadena.dev.ndmf" -permissions: - contents: write jobs: - build: + run-tests: + needs: prechecks + if: needs.prechecks.outputs.need-new-tag == 'true' + uses: bdunderscore/ndmf/.github/workflows/gameci.yml@main + prechecks: runs-on: ubuntu-latest + needs: run-tests + outputs: + version: ${{ steps.version.outputs.prop }} + need-new-tag: ${{ steps.check-tag.outputs.need-new-tag }} steps: - name: Checkout uses: actions/checkout@v3 + - name: get version + id: version + uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8 + with: + path: "package.json" + prop_path: "version" + + - name: Check if version is tagged + id: check-tag + run: | + if git fetch origin $current_version --depth=1; then + echo "Version $current_version is already tagged" + echo "need-new-tag=false" >> $GITHUB_OUTPUT + else + echo "Version $current_version is not tagged" + echo "need-new-tag=true" >> $GITHUB_OUTPUT + fi + + - name: Verify that this is the first revision with this version + if: steps.check_tagged.outputs.need_tag == 'true' + run: | + git fetch --unshallow + git checkout HEAD~ package.json + if [ "$(jq -r .version package.json)" == "$current_version" ]; then + echo "Error: Looks like we skipped the version bump commit." + exit 1 + fi + - name: Check semver syntax + if: steps.check_tagged.outputs.need_tag == 'true' id: semver-check + run: | + chmod +x .github/scripts/*.sh + .github/scripts/check-semver.sh ${{ steps.version.outputs.prop }} + + - name: Check tag consistency 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" + 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 - - name: get version + create-release: + needs: [prechecks, run-tests] + runs-on: ubuntu-latest + if: needs.prechecks.outputs.need-new-tag == 'true' || startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Reexport version id: version - uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8 - with: - path: "package.json" - prop_path: "version" + run: | + echo "version=${{ needs.prechecks.outputs.version }}" >> $GITHUB_ENV + + # Re-check semver syntax in case this is being triggered by a manual tag push + - name: Check semver syntax + if: steps.check_tagged.outputs.need_tag == 'true' + id: semver-check + run: | + chmod +x .github/scripts/*.sh + .github/scripts/check-semver.sh ${{ steps.version.outputs.prop }} - name: Check tag consistency if: startsWith(github.ref, 'refs/tags/') @@ -48,8 +101,6 @@ jobs: exit 1 fi - - run: echo ${{steps.version.outputs.prop}} - - name: Set Environment Variables run: | echo "zipFile=${{ env.packageName }}-${{ steps.version.outputs.prop }}".zip >> $GITHUB_ENV @@ -71,6 +122,14 @@ jobs: with: name: package-zip path: ${{ env.zipFile }} + + - name: Create tag + if: needs.prechecks.outputs.need-new-tag == 'true' + run: | + git config user.name "Github Actions" + git config user.email "github-actions@nadena.dev" + git tag ${{ steps.version.outputs.prop }} + git push origin ${{ steps.version.outputs.prop }} - name: Make Release uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 diff --git a/.github/workflows/check-semver-syntax.sh b/.github/workflows/check-semver-syntax.sh new file mode 100644 index 0000000..640ecb7 --- /dev/null +++ b/.github/workflows/check-semver-syntax.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -x + +if echo $1 | grep '[a-z]-[0-9]' > /dev/null; then + echo "Tag name does not follow semver prerelease syntax: $REF_NAME" + exit 1 +fi \ No newline at end of file diff --git a/.github/workflows/gameci.yml b/.github/workflows/gameci.yml index 189fe9a..fb72f42 100644 --- a/.github/workflows/gameci.yml +++ b/.github/workflows/gameci.yml @@ -40,7 +40,8 @@ jobs: build-and-test: strategy: matrix: - unity_version: [ auto, 2022.3.5f1 ] + #unity_version: [ auto, 2022.3.5f1 ] + unity_version: auto runs-on: ubuntu-latest permissions: checks: write diff --git a/.github/workflows/release-tagging.yml b/.github/workflows/release-tagging.yml deleted file mode 100644 index f5e27eb..0000000 --- a/.github/workflows/release-tagging.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Tag releases -on: - workflow_call: - -permissions: - contents: write - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Get current version - run: | - echo current_version=$(jq -r .version package.json) >> $GITHUB_ENV - - name: Check if version is tagged - id: check_tagged - run: | - if git fetch origin $current_version --depth=1; then - echo "Version $current_version is already tagged" - echo "need_tag=false" >> $GITHUB_OUTPUT - else - echo "Version $current_version is not tagged" - echo "need_tag=true" >> $GITHUB_OUTPUT - fi - - name: Verify that this is the first revision with this version - if: steps.check_tagged.outputs.need_tag == 'true' - run: | - git fetch --unshallow - git checkout HEAD~ package.json - if [ "$(jq -r .version package.json)" == "$current_version" ]; then - echo "Error: Looks like we skipped the version bump commit." - exit 1 - fi - - name: Tag version - if: steps.check_tagged.outputs.need_tag == 'true' - run: | - git config user.name "Github Actions" - git config user.email "github-actions@nadena.dev" - git tag $current_version - git push origin $current_version diff --git a/package.json b/package.json index 3f16468..469d43f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nadena.dev.ndmf", "displayName": "Non-Destructive Modular Framework", - "version": "0.4.1-ci-test.2", + "version": "0.4.1-ci-test.3", "unity": "2019.4", "description": "A framework for building non-destructive plugins for VRChat Avatar 3.0", "vrchatVersion": "2022.1.1",