build: 迁移 sln 到 slnx 格式 #6
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: Publish Release | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| if: "!startsWith(github.event.head_commit.message, 'chore(release)')" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Get latest tag | |
| id: tag | |
| run: | | |
| latest=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0") | |
| echo "tag=$latest" >> $GITHUB_OUTPUT | |
| - name: Analyze commits and calculate version | |
| id: version | |
| uses: paulhatch/semantic-version@v5.4.0 | |
| with: | |
| tag_prefix: "" | |
| major_pattern: "BREAKING CHANGE:" | |
| minor_pattern: "feat" | |
| format: "${major}.${minor}.${patch}" | |
| - name: Check if release needed | |
| id: check | |
| run: | | |
| if [ "${{ steps.version.outputs.version }}" != "${{ steps.tag.outputs.tag }}" ]; then | |
| echo "need_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "need_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Lowercase repository name | |
| id: repo | |
| run: echo "lowercase=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT | |
| - name: Generate CHANGELOG | |
| if: steps.check.outputs.need_release == 'true' | |
| uses: orhun/git-cliff-action@v4 | |
| id: git-cliff | |
| with: | |
| config: cliff.toml | |
| args: --tag ${{ steps.version.outputs.version }} --strip header | |
| env: | |
| OUTPUT: CHANGELOG.md | |
| GITHUB_REPO: ${{ github.repository }} | |
| - name: Commit changes | |
| if: steps.check.outputs.need_release == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add CHANGELOG.md | |
| git commit -m "chore(release): ${{ steps.version.outputs.version }}" | |
| - name: Set up Docker Buildx | |
| if: steps.check.outputs.need_release == 'true' | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| if: steps.check.outputs.need_release == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Login to GitHub Container Registry | |
| if: steps.check.outputs.need_release == 'true' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| if: steps.check.outputs.need_release == 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| tags: | | |
| ${{ secrets.DOCKERHUB_ORGANIZATION }}/gameframex-tools:${{ steps.version.outputs.version }} | |
| ${{ secrets.DOCKERHUB_ORGANIZATION }}/gameframex-tools:latest | |
| ghcr.io/${{ steps.repo.outputs.lowercase }}:${{ steps.version.outputs.version }} | |
| ghcr.io/${{ steps.repo.outputs.lowercase }}:latest | |
| - name: Push changes | |
| if: steps.check.outputs.need_release == 'true' | |
| run: | | |
| git push origin main | |
| git tag ${{ steps.version.outputs.version }} | |
| git push origin ${{ steps.version.outputs.version }} | |
| - name: Create GitHub Release | |
| if: steps.check.outputs.need_release == 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.version.outputs.version }} | |
| body_path: CHANGELOG.md | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |