README.md #788
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: .NET | |
on: push | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
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 -c release | |
- name: Test | |
run: dotnet test --no-build --verbosity normal | |
- name: Min | |
run: > | |
dotnet publish -c release -p:PublishDir=../dist/min --no-self-contained | |
-p:PublishSingleFile=true -p:DebugType=embedded -p:PublishTrimmed=false | |
-p:EnableCompressionInSingleFile=false --use-current-runtime Elib2EbookCli | |
- name: Portable | |
run: > | |
dotnet publish -c release -p:PublishDir=../dist/portable --self-contained | |
-p:PublishSingleFile=true -p:DebugType=embedded | |
-p:EnableCompressionInSingleFile=true --use-current-runtime Elib2EbookCli | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Elib2Ebook-${{ matrix.os }}-min | |
path: ${{ github.workspace }}/dist/min | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: Elib2Ebook-${{ matrix.os }}-portable | |
path: ${{ github.workspace }}/dist/portable | |
check_version: | |
name: Check version | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
outputs: | |
VERSION: ${{ steps.get-version.outputs.version }} | |
LAST_TAG: ${{ steps.last_release.outputs.tag_name }} | |
steps: | |
- name: check repository | |
uses: actions/checkout@v4 | |
- uses: kzrnm/get-net-sdk-project-versions-action@v2 | |
id: get-version | |
with: | |
proj-path: Core/Core.csproj | |
- name: "get-last-release" | |
id: last_release | |
uses: InsonusK/[email protected] | |
with: | |
myToken: ${{ github.token }} | |
push_to_registry: | |
name: push docker image to hub | |
runs-on: ubuntu-latest | |
needs: check_version | |
if: ${{ needs.check_version.outputs.LAST_TAG != needs.check_version.outputs.VERSION }} | |
strategy: | |
matrix: | |
folder: [ Elib2EbookCli, Elib2EbookWeb ] | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: check repository | |
uses: actions/checkout@v4 | |
- name: login to docker registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{secrets.DOCKERHUB_USERNAME}} | |
password: ${{secrets.DOCKERHUB_TOKEN}} | |
- id: string | |
uses: ASzc/change-string-case-action@v6 | |
with: | |
string: ${{ matrix.folder }} | |
- name: build and push docker image to registry | |
uses: docker/build-push-action@v6 | |
with: | |
platforms: linux/amd64, linux/arm64 | |
file: "${{ matrix.folder }}/Dockerfile" | |
push: true | |
tags: ${{secrets.DOCKERHUB_NAMESPACE}}/${{ steps.string.outputs.lowercase }}:${{ needs.check_version.outputs.VERSION }},${{secrets.DOCKERHUB_NAMESPACE}}/${{ steps.string.outputs.lowercase }}:latest | |
create_release: | |
needs: check_version | |
runs-on: ubuntu-latest | |
if: ${{ needs.check_version.outputs.LAST_TAG != needs.check_version.outputs.VERSION }} | |
outputs: | |
UPLOAD_URL: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
draft: false | |
prerelease: false | |
release_name: ${{needs.check_version.outputs.VERSION}} | |
tag_name: ${{needs.check_version.outputs.VERSION}} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
upload_release: | |
needs: create_release | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-latest, windows-latest ] | |
version: [ min, portable ] | |
steps: | |
- name: download-artifact-${{ matrix.os }}-${{ matrix.version }} | |
uses: actions/download-artifact@v4 | |
with: | |
name: Elib2Ebook-${{ matrix.os }}-${{ matrix.version }} | |
path: ${{ github.workspace }}/${{ matrix.os }}-${{ matrix.version }} | |
- name: Install zip | |
uses: montudor/[email protected] | |
- name: Zip output | |
run: zip -qq -x "*.pdb" -r ../Elib2Ebook-${{ matrix.os }}-${{ matrix.version }}.zip . | |
working-directory: ${{ github.workspace }}/${{ matrix.os }}-${{ matrix.version }} | |
- name: upload ${{ matrix.os }}-${{ matrix.version }} asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.create_release.outputs.UPLOAD_URL }} | |
asset_path: Elib2Ebook-${{ matrix.os }}-${{ matrix.version }}.zip | |
asset_name: Elib2Ebook-${{ matrix.os }}-${{ matrix.version }}.zip | |
asset_content_type: application/zip | |