From 5aa3f7dcd0695b8638396c7e302a0763559128b6 Mon Sep 17 00:00:00 2001 From: ElderJames Date: Mon, 1 Mar 2021 16:34:46 +0800 Subject: [PATCH] chore: adjusting the release cycle and versioning --- .../{gh-pages.yml => nightly-build.yml} | 91 ++++++++++++------- .github/workflows/release.yml | 39 +++++++- 2 files changed, 96 insertions(+), 34 deletions(-) rename .github/workflows/{gh-pages.yml => nightly-build.yml} (51%) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/nightly-build.yml similarity index 51% rename from .github/workflows/gh-pages.yml rename to .github/workflows/nightly-build.yml index 5fd87ea6..7a3ad741 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/nightly-build.yml @@ -1,13 +1,13 @@ ο»Ώname: Publish Docs env: - Version: 0.7.0 NUGET_API_KEY: ${{secrets.NUGET_API_KEY}} on: push: branches: - master + - feature jobs: publish-and-deploy: @@ -43,17 +43,63 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: 'Get Last Release' + id: previoustag + run: | + git fetch --tags + # This suppress an error occurred when the repository is a complete one. + git fetch --prune --unshallow || true + LAST_VERSION=$(git describe --abbrev=0 --tags) + echo "Last Version: ${LAST_VERSION}" + echo "::set-output name=previous_tag::${LAST_VERSION}" + + - name: 'Get Next Semantic Version' + id: semvers + uses: "WyriHaximus/github-action-next-semvers@v1" + with: + version: ${{ steps.previoustag.outputs.previous_tag }} + + - name: 'Get Next Version' + id: get_next_version + run: | + current_branch=$(git symbolic-ref --short -q HEAD) + echo Current git branch is $current_branch + next_version='' + if [ "$current_branch" == 'master' ] ; + then + next_version=$patch_version + else + next_version=$minor_version + fi + echo Will release version $next_version for branch $current_branch + echo "::set-output name=next_version::${next_version}" + echo "::set-output name=current_branch::${current_branch}" + env: + patch_version: ${{ steps.semvers.outputs.patch }} + minor_version: ${{ steps.semvers.outputs.minor }} + - name: Package Nightly Nuget πŸ“¦ id: pack run: | - FULL_VERSION=$Version-nightly-`date "+%y%m%d%H%M"` + FULL_VERSION=$next_version-nightly-`date "+%y%m%d%H%M"` echo "Version: ${FULL_VERSION}" echo "::set-output name=package_version::${FULL_VERSION}" dotnet pack components/AntDesign.csproj /p:PackageVersion=${FULL_VERSION} -c Release -o publish + env: + next_version: ${{ steps.get_next_version.outputs.next_version }} - - name: Publish to Nuget βœ” - run: | - dotnet nuget push publish/*.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_API_KEY --skip-duplicate + - name: Push to GitHub package registry + run: dotnet nuget push ./publish/*.nupkg --source ${{ env.REPOSITORY_URL }} --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate --no-symbols true + env: + REPOSITORY_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json + + - name: Sync to Gitee πŸ’• + uses: wearerequired/git-mirror-action@master + env: + SSH_PRIVATE_KEY: ${{ secrets.GITEE_PRIVATE_KEY }} + with: + source-repo: "git@github.com:ant-design-blazor/ant-design-blazor.git" + destination-repo: "git@gitee.com:ant-design-blazor/ant-design-blazor.git" - name: Publish Docs πŸŽ‰ run: | @@ -64,33 +110,12 @@ jobs: sed -i s/{version}/$PACKAGE_VERSION/g ./site/AntDesign.Docs/Shared/HeaderMenu.razor dotnet publish ./site/AntDesign.Docs.Wasm -c Release -f net5 -o cargo env: - PACKAGE_VERSION: ${{ steps.pack.outputs.package_version }} + PACKAGE_VERSION: ${{ steps.get_next_version.outputs.next_version }} - - name: Deploy πŸš€ - uses: JamesIves/github-pages-deploy-action@releases/v3 - with: - ACCESS_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} - BRANCH: gh-pages - FOLDER: cargo/wwwroot - - - name: Deploy to Github.io πŸš€ - uses: peaceiris/actions-gh-pages@v3 - with: - personal_token: ${{ secrets.GH_PUSH_TOKEN }} - external_repository: ant-design-blazor/ant-design-blazor.github.io - publish_branch: master - publish_dir: ./cargo/wwwroot - cname: antblazor.com - tag_name: ${{ steps.pack.outputs.package_version }} - - - name: Sync to Gitee πŸ’• - uses: wearerequired/git-mirror-action@master + - name: Deploy Preview πŸš€ + run: | + npm install -g surge + surge --project ./cargo/wwwroot --domain $BRANCH-antblazor.surge.sh env: - SSH_PRIVATE_KEY: ${{ secrets.GITEE_PRIVATE_KEY }} - with: - source-repo: "git@github.com:ant-design-blazor/ant-design-blazor.git" - destination-repo: "git@gitee.com:ant-design-blazor/ant-design-blazor.git" - - # - name: 🧹Purge jsDeliver CDN - # run: | - # bash ./scripts/purge-jsdelivr.sh ./cargo/wwwroot ant-design-blazor/ant-design-blazor.github.io + SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} + BRANCH: ${{ steps.get_next_version.outputs.current_branch }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1a4a2225..0d6c41c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,44 @@ jobs: run: | VERSION=`git describe --tags` echo "Publishing Version: ${VERSION}" + echo "::set-output name=package_version::${VERSION}" npm install dotnet build components/AntDesign.csproj dotnet pack components/AntDesign.csproj /p:PackageVersion=$VERSION -c Release -o publish - dotnet nuget push publish/*.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_API_KEY --skip-duplicate \ No newline at end of file + dotnet nuget push publish/*.nupkg -s https://api.nuget.org/v3/index.json -k $NUGET_API_KEY --skip-duplicate + + - name: Publish Docs πŸŽ‰ + run: | + npm install + echo "/* updated `date "+%Y-%m-%d %H:%M:%S"` */" >> ./site/AntDesign.Docs.Wasm/wwwroot/service-worker.published.js + cp -rf scripts/gh-pages/* scripts/gh-pages/.nojekyll scripts/gh-pages/.spa ./site/AntDesign.Docs.Wasm/wwwroot + sed -i s/{version}/$PACKAGE_VERSION/g ./site/AntDesign.Docs.Wasm/wwwroot/index.html + sed -i s/{version}/$PACKAGE_VERSION/g ./site/AntDesign.Docs/Shared/HeaderMenu.razor + dotnet publish ./site/AntDesign.Docs.Wasm -c Release -f net5 -o cargo + env: + PACKAGE_VERSION: ${{ steps.pack.outputs.package_version }} + + - name: Deploy πŸš€ + uses: JamesIves/github-pages-deploy-action@releases/v3 + with: + ACCESS_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} + BRANCH: gh-pages + FOLDER: cargo/wwwroot + + - name: Deploy to Github.io πŸš€ + uses: peaceiris/actions-gh-pages@v3 + with: + personal_token: ${{ secrets.GH_PUSH_TOKEN }} + external_repository: ant-design-blazor/ant-design-blazor.github.io + publish_branch: master + publish_dir: ./cargo/wwwroot + cname: antblazor.com + tag_name: ${{ steps.pack.outputs.package_version }} + + - name: Sync to Gitee πŸ’• + uses: wearerequired/git-mirror-action@master + env: + SSH_PRIVATE_KEY: ${{ secrets.GITEE_PRIVATE_KEY }} + with: + source-repo: "git@github.com:ant-design-blazor/ant-design-blazor.git" + destination-repo: "git@gitee.com:ant-design-blazor/ant-design-blazor.git"