Publish Release #34
This file contains 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: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version to publish (e.g., 2.0.6)' | |
required: true | |
type: string | |
env: | |
APP_NAME: place.api | |
SOLUTION: Place.sln | |
API_PROJECT: src/Place.API/Place.API.csproj | |
RUNTIME: linux-x64 | |
DOCKER_REPO: ${{ secrets.PLACE_DOCKER_HUB_REPO }} | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.0.x' | |
- name: Extract Architecture from Runtime | |
run: | | |
ARCH=$(echo ${{ env.RUNTIME }} | sed -E 's/.*-(x64|arm64)$/\1/') | |
echo "DOCKER_ARCH=$ARCH" >> $GITHUB_ENV | |
echo "Detected architecture: $ARCH" | |
- name: Publish .NET Application | |
run: make publish RUNTIME=${{ env.RUNTIME }} API_PROJECT=${{ env.API_PROJECT }} APP_NAME=${{ env.APP_NAME }} | |
- name: Create ZIP file | |
run: | | |
cd publish | |
zip -r ../${{ env.APP_NAME }}-${{ env.RUNTIME }}.zip ${{ env.RUNTIME }}/* | |
- name: Upload Release Asset | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload v${{ inputs.version }} \ | |
${{ env.APP_NAME }}-${{ env.RUNTIME }}.zip \ | |
--clobber | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.PLACE_DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.PLACE_DOCKER_HUB_TOKEN }} | |
- name: Build and Push Docker Image | |
run: | | |
make docker \ | |
RUNTIME=${{ env.RUNTIME }} \ | |
APP_NAME=${{ env.APP_NAME }} \ | |
VERSION=api-${{ inputs.version }} \ | |
DOCKER_REPO=${{ env.DOCKER_REPO }} | |
docker push ${{ env.DOCKER_REPO }}:api-${{ inputs.version }}-${{ env.DOCKER_ARCH }} | |
docker tag ${{ env.DOCKER_REPO }}:api-${{ inputs.version }}-${{ env.DOCKER_ARCH }} \ | |
${{ env.DOCKER_REPO }}:api-latest | |
docker push ${{ env.DOCKER_REPO }}:api-latest |