This commit is contained in:
Ivan Bushchik 2022-01-13 18:06:16 +03:00
parent c6fe02ca87
commit a307c0795e
3 changed files with 60 additions and 120 deletions

View file

@ -1,18 +0,0 @@
name: Docker Image CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag my-image-name:$(date +%s)

View file

@ -1,63 +0,0 @@
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
schedule:
- cron: '18 6 * * *'
push:
branches: [ master ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ master ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View file

@ -6,43 +6,64 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Publish on osx-x64
run: dotnet publish --runtime osx-x64 -o publish/osx-x64/ --self-contained -p:PublishSingleFile=true
- name: Publish on linux-x64
run: dotnet publish --runtime linux-x64 -o publish/linux-x64/ --self-contained -p:PublishSingleFile=true
- name: Publish on linux-arm64
run: dotnet publish --runtime linux-arm64 -o publish/linux-arm64/ --self-contained -p:PublishSingleFile=true
- name: Compress to zip file
run: tar cf roulette.tar.gz publish/
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Prepare for publishing
run: mkdir prepublish && mkdir publish
- name: Publish on osx-x64
run: dotnet publish --runtime osx-x64 -o prepublish/osx-x64/ --self-contained -p:PublishSingleFile=true && mv prepublish/osx-x64/roulette publish/roulette-osx-x64
- name: Publish on linux-x64
run: dotnet publish --runtime linux-x64 -o prepublish/linux-x64/ --self-contained -p:PublishSingleFile=true && mv prepublish/linux-x64/roulette publish/roulette-linux-x64
- name: Publish on linux-arm64
run: dotnet publish --runtime linux-arm64 -o prepublish/linux-arm64/ --self-contained -p:PublishSingleFile=true && mv prepublish/linux-arm64/roulette publish/roulette-linux-arm64
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: True
prerelease: False
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./roulette.tar.gz
asset_name: roulette.tar.gz
asset_content_type: application/gzip
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: EDITME
release_name: EDITME
draft: True
prerelease: False
- name: Upload Release Asset for osx-x64
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: publish/roulette-osx-x64
asset_name: roulette-osx-x64
- name: Upload Release Asset for linux-x64
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: publish/roulette-linux-x64
asset_name: roulette-linux-x64
- name: Upload Release Asset for linux-arm64
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: publish/roulette-linux-arm64
asset_name: roulette-linux-arm64