Release Web #1
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: Release Web | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| validate: | |
| name: Validate version | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.read_version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Read version from semver.txt | |
| id: read_version | |
| run: | | |
| version=$(tr -d '[:space:]' < src/CoderPatros.Tea.Web/semver.txt) | |
| echo "version=$version" >> "$GITHUB_OUTPUT" | |
| - name: Validate semver format | |
| run: | | |
| if ! echo "${{ steps.read_version.outputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$'; then | |
| echo "::error::Version '${{ steps.read_version.outputs.version }}' is not valid semver" | |
| exit 1 | |
| fi | |
| - name: Check tag does not exist | |
| run: | | |
| if git ls-remote --tags https://github.com/${{ github.repository }} | grep -q "refs/tags/web/v${{ steps.read_version.outputs.version }}$"; then | |
| echo "::error::Tag web/v${{ steps.read_version.outputs.version }} already exists" | |
| exit 1 | |
| fi | |
| test: | |
| name: Test (${{ matrix.os }}) | |
| needs: validate | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '8.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build --no-restore | |
| - name: Test | |
| run: dotnet test --no-build --verbosity normal | |
| release: | |
| name: Release | |
| needs: [validate, test] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| env: | |
| VERSION: ${{ needs.validate.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: src/CoderPatros.Tea.Web/Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| coderpatros/tea-web:${{ env.VERSION }} | |
| coderpatros/tea-web:latest | |
| - name: Create and push tag | |
| run: | | |
| git tag "web/v${{ env.VERSION }}" | |
| git push origin "web/v${{ env.VERSION }}" | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: web/v${{ env.VERSION }} | |
| name: Web v${{ env.VERSION }} | |
| generate_release_notes: true |