diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9261c3..db7144f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,84 +3,58 @@ on: push: branches: - main + jobs: release: name: ⚙ Release runs-on: ubuntu-latest + env: + PROJECT_NAME: extDebug + PROJECT_ASSETS: README.md:CHANGELOG.md:LICENSE steps: - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Build unitypackage - run: | - echo Assets/extDebug.meta >> metaList - find Assets/extDebug -name \*.meta >> metaList - - uses: pCYSl5EDgo/create-unitypackage@master - with: - package-path: extDebug.unitypackage - include-files: metaList - project-folder: ./ - - name: Semantic release + - name: Semantic Release id: semantic uses: cycjimmy/semantic-release-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: + branch: main extra_plugins: | - @semantic-release/changelog + @semantic-release/changelog @semantic-release/git - branch: main - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Update upm branch + @iam1337/create-unitypackage + - name: Push UPM update run: | - echo '>>> Start' - git log -1 + IFS=: read -r -a PROJECT_ASSETS_ARRAY <<< "$PROJECT_ASSETS" mkdir Temp - cp README.md Temp/README.md - cp CHANGELOG.md Temp/CHANGELOG.md - cp LICENSE Temp/LICENSE - - echo '>>> Delete local upm branch' - git branch -d upm &> /dev/null || echo upm branch not found - - echo - echo '>>> Split upm branch' - git subtree split -P "$PKG_ROOT" -b upm + for asset in "${PROJECT_ASSETS_ARRAY[@]}"; do + cp ${asset} Temp/${asset} + done - echo - echo '>>> Checkout upm branch' + git log -1 + git subtree split -P "Assets/$PROJECT_NAME" -b upm git checkout upm - cp Temp/README.md README.md - git add README.md - - cp Temp/CHANGELOG.md CHANGELOG.md - git add CHANGELOG.md - - cp Temp/LICENSE LICENSE - git add LICENSE + for asset in "${PROJECT_ASSETS_ARRAY[@]}"; do + cp Temp/${asset} ${asset} + git add ${asset} + done if [[ -d "Examples" ]]; then - echo - echo '>>> Examples move to Examples~' git mv Examples Examples~ rm -f Examples.meta fi - git config --global user.name 'github-bot' - git config --global user.email 'github-bot@users.noreply.github.com' - git commit -am "$MSG" - - echo - echo '>>> Force overwrite remote upm branch' + git config user.name github-actions + git config user.email github-actions@github.com + git commit -am "chore(release): update upm branch [skip ci]" git push -f -u origin upm - env: - PKG_ROOT: Assets/extDebug - MSG: "chore(release): finalize UPM package" - - name: Create upm git tag + - name: Push UPM tag if: steps.semantic.outputs.new_release_published == 'true' + env: + UPM_TAG: upm/v${{ steps.semantic.outputs.new_release_version }} run: | - git tag $TAG upm - git push origin --tags - env: - TAG: upm/v${{ steps.semantic.outputs.new_release_version }} + git tag $UPM_TAG upm + git push origin --tags \ No newline at end of file diff --git a/.releaserc.json b/.releaserc.json deleted file mode 100644 index 95bbe19..0000000 --- a/.releaserc.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "tagFormat": "v${version}", - "plugins": [ - ["@semantic-release/commit-analyzer", { "preset": "angular" }], - "@semantic-release/release-notes-generator", - ["@semantic-release/changelog", { "preset": "angular" }], - ["@semantic-release/npm", { "npmPublish": false, "pkgRoot": "Assets/extDebug" }], - ["@semantic-release/git", { - "assets": ["Assets/extDebug/package.json", "CHANGELOG.md"], - "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - }], - ["@semantic-release/github", { - "assets": [ - {"path": "extDebug.unitypackage", "label": "extDebug v${nextRelease.version}"} - ] - }] - ] -} \ No newline at end of file diff --git a/release.config.js b/release.config.js new file mode 100644 index 0000000..b95c35d --- /dev/null +++ b/release.config.js @@ -0,0 +1,39 @@ +module.exports = { + "branches" : "main", + "tagFormat": "v${version}", + "plugins": [ + ["@semantic-release/commit-analyzer", { + "preset": "angular", + "releaseRules" : [ + {"type": "docs", "release": "patch"}, + {"type": "docs", "scope": "README", "release": false} + ] + }], + ["@semantic-release/release-notes-generator", { + "writerOpts": { + "commitsSort": ["scope", "subject"] + } + }], + ["@semantic-release/changelog", { + "changelogFile": "CHANGELOG.md" + }], + ["@semantic-release/npm", { + "npmPublish": false, + "pkgRoot": `Assets/${process.env.PROJECT_NAME}` }], + ["@semantic-release/git", { + "assets": [`Assets/${process.env.PROJECT_NAME}/package.json`, "CHANGELOG.md"], + "message": "chore(release): new release ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + }], + ["@iam1337/create-unitypackage", { + "packageRoot": `Assets/${process.env.PROJECT_NAME}`, + "projectRoot": "./", + "output": `${process.env.PROJECT_NAME}.unitypackage` + }], + ["@semantic-release/github", { + "assets": [ + {"path": `${process.env.PROJECT_NAME}.unitypackage`, "label": `${process.env.PROJECT_NAME} v\${nextRelease.version}`} + ] + }] + ], + "preset": "angular" +} \ No newline at end of file