Skip to content

nuget: Bump Tomlyn from 0.19.0 to 1.2.0 #102

nuget: Bump Tomlyn from 0.19.0 to 1.2.0

nuget: Bump Tomlyn from 0.19.0 to 1.2.0 #102

Workflow file for this run

name: Release
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
env:
REGISTRY_IMAGE: ghcr.io/ochronus/csharparr
DOTNET_VERSION: "10.0.x"
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore -c Release
- name: Run tests
run: dotnet test --no-build -c Release --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
directory: ./coverage
fail_ci_if_error: false
build:
name: Build
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
include:
- os: ubuntu-latest
target: linux-x64
- os: ubuntu-latest
target: linux-arm64
- os: macos-latest
target: osx-x64
- os: macos-latest
target: osx-arm64
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
- name: Build self-contained binary
run: |
dotnet publish src/Csharparr/Csharparr.csproj \
-c Release \
-r ${{ matrix.target }} \
--self-contained true \
-p:PublishSingleFile=true \
-p:PublishTrimmed=false \
-p:IncludeNativeLibrariesForSelfExtract=true \
-p:EnableCompressionInSingleFile=true \
-o ./publish
- name: Rename artifact
run: mv ./publish/csharparr ./publish/csharparr-${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: csharparr-${{ matrix.target }}
path: ./publish/csharparr-${{ matrix.target }}
retention-days: 7
release:
name: Release
runs-on: ubuntu-latest
needs: build
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
cd artifacts
for dir in */; do
target="${dir%/}"
target="${target#csharparr-}"
cp "$dir/csharparr-$target" "../release/csharparr-$target"
done
cd ../release
for file in *; do
sha256sum "$file" > "$file.sha256"
done
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release/*
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
docker:
name: Docker Build and Push
runs-on: ubuntu-latest
needs: test
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine image tags
id: docker_tags
run: |
TAGS=""
REF="${{ github.ref }}"
REF_NAME="${{ github.ref_name }}"
REGISTRY="${{ env.REGISTRY_IMAGE }}"
if [[ "$REF" == refs/tags/* ]]; then
VERSION="$REF_NAME"
TAGS="$REGISTRY:latest,$REGISTRY:$VERSION"
elif [[ "$REF" == refs/heads/main ]]; then
TAGS="$REGISTRY:main-latest"
else
TAGS="$REGISTRY:${{ github.sha }}"
fi
echo "TAGS=$TAGS" >> $GITHUB_OUTPUT
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_tags.outputs.TAGS }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max