Skip to content

Merge pull request #12 from DMiradakis/main #27

Merge pull request #12 from DMiradakis/main

Merge pull request #12 from DMiradakis/main #27

name: Publish to prod
on:
push:
tags:
- 'v*'
env:
APP_NAME: Resolver
jobs:
verify:
name: Verify tag is on production
runs-on: ubuntu-latest
steps:
- name: Checkout git repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Verify tag is on production branch
run: |
BRANCHES=$(git branch -r --contains ${{ github.ref }})
if ! echo "$BRANCHES" | grep -q "origin/production"; then
echo "Error: Tag must be on production branch"
echo "Tag is on: $BRANCHES"
exit 1
fi
build:
needs: verify # Only run if verify passes
name: Build ${{ matrix.os }}-${{ matrix.arch }}
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- os: linux
arch: x64
runner: ubuntu-latest
rid: linux-x64
- os: linux
arch: arm64
runner: ubuntu-24.04-arm
rid: linux-arm64
- os: macos
arch: x64
runner: macos-15-intel
rid: osx-x64
- os: macos
arch: arm64
runner: macos-latest
rid: osx-arm64
- os: windows
arch: x64
runner: windows-latest
rid: win-x64
- os: windows
arch: arm64
runner: windows-11-arm
rid: win-arm64
steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Publish (Unix)
if: matrix.os != 'windows'
run: |
dotnet publish src/${{ env.APP_NAME }}/${{ env.APP_NAME }}.csproj \
-c Release \
-r ${{ matrix.rid }} \
-o ./publish
- name: Publish (Windows)
if: matrix.os == 'windows'
shell: pwsh
run: |
dotnet publish src/${{ env.APP_NAME }}/${{ env.APP_NAME }}.csproj `
-c Release `
-r ${{ matrix.rid }} `
-o ./publish
- name: Rename binary (Unix)
if: matrix.os != 'windows'
run: |
cd publish
mv ${{ env.APP_NAME }} ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
- name: Rename binary (Windows)
if: matrix.os == 'windows'
shell: pwsh
run: |
cd publish
Move-Item ${{ env.APP_NAME }}.exe ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.APP_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
path: publish/${{ env.APP_NAME }}-*
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Generate SHA256 checksums
run: |
cd artifacts
find . -type f ! -name 'checksums.sha256' -exec sha256sum {} \; > checksums.sha256
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
files: artifacts/**/*
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}