Skip to content

Commit

Permalink
Merge pull request #55 from MCOfficer/actions
Browse files Browse the repository at this point in the history
Github Actions Revamp
  • Loading branch information
KoalaBear84 authored Dec 2, 2020
2 parents 1026377 + 130798a commit 465af36
Showing 1 changed file with 69 additions and 219 deletions.
288 changes: 69 additions & 219 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,48 @@ on:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build:

runs-on: windows-latest

env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_NOLOGO: 1

strategy:
matrix:
target:
- linux-x64
- linux-arm
- linux-arm64
- win-x64
- osx-x64
self-contained:
- normal
- self-contained
include:
- target: linux-x64
os: ubuntu-latest
- target: linux-arm
os: ubuntu-latest
- target: linux-arm64
os: ubuntu-latest
- target: win-x64
os: windows-latest
- target: osx-x64
os: macos-latest

- self-contained: normal
build_args: --no-self-contained
suffix: ""
- self-contained: self-contained
build_args: --self-contained=true
suffix: "-self-contained"

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
Expand All @@ -25,256 +59,72 @@ jobs:
with:
dotnet-version: 5.0.100



- name: Get version info
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v}
shell: bash



- name: Build with dotnet
run: dotnet build OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }}

- name: Test with dotnet
run: dotnet test OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }}



- name: Publish with dotnet win-x64
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime win-x64 --no-self-contained -p:PublishSingleFile=true --output ./OpenDirectoryDownloader-win-x64

- name: Zipping win-x64
uses: papeloto/action-zip@v1
with:
files: ./OpenDirectoryDownloader-win-x64
dest: OpenDirectoryDownloader-win-x64.zip
- name: Publish with dotnet
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime ${{ matrix.target }} ${{ matrix.build_args }} -p:PublishSingleFile=true --output ./OpenDirectoryDownloader-${{ matrix.target }}${{ matrix.suffix }}

- name: Publish with dotnet win-x64 (self-contained)
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime win-x64 --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:IncludeNativeLibrariesForSelfExtract=true --output ./OpenDirectoryDownloader-win-x64-self-contained

- name: Zipping win-x64 (self-contained)
uses: papeloto/action-zip@v1
with:
files: ./OpenDirectoryDownloader-win-x64-self-contained
dest: OpenDirectoryDownloader-win-x64-self-contained.zip



- name: Publish with dotnet linux-x64
- name: Set executable bit (linux only)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime linux-x64 --no-self-contained -p:PublishSingleFile=true --output ./OpenDirectoryDownloader-linux-x64
chmod +x ./OpenDirectoryDownloader-linux-x64/OpenDirectoryDownloader
- name: Zipping linux-x64
uses: papeloto/action-zip@v1
with:
files: ./OpenDirectoryDownloader-linux-x64
dest: OpenDirectoryDownloader-linux-x64.zip

- name: Publish with dotnet linux-x64 (self-contained)
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime linux-x64 --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:IncludeNativeLibrariesForSelfExtract=true --output ./OpenDirectoryDownloader-linux-x64-self-contained

- name: Zipping linux-x64 (self-contained)
uses: papeloto/action-zip@v1
with:
files: ./OpenDirectoryDownloader-linux-x64-self-contained
dest: OpenDirectoryDownloader-linux-x64-self-contained.zip

chmod +x ./OpenDirectoryDownloader-${{ matrix.target }}${{ matrix.suffix }}/OpenDirectoryDownloader
- name: Zipping
run: |
7z a OpenDirectoryDownloader-${{ matrix.target }}${{ matrix.suffix }}.zip ./OpenDirectoryDownloader-${{ matrix.target }}${{ matrix.suffix }}/*
# 7z is installed in all environments and supports unix permissions while compressing (but not while decompressing!)
- name: Upload artifact linux-x64
- name: Upload artifact for docker job (linux-x64 normal only)
if: ${{ matrix.target == 'linux-x64' && matrix.self-contained == 'normal' }}
uses: actions/upload-artifact@v2
with:
name: linux-x64
path: |
OpenDirectoryDownloader-linux-x64.zip
OpenDirectoryDownloader-${{ matrix.target }}${{ matrix.suffix }}.zip
Dockerfile
- name: Publish with dotnet linux-arm64
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime linux-arm64 --no-self-contained -p:PublishSingleFile=true --output ./OpenDirectoryDownloader-linux-arm64

- name: Zipping linux-arm64
uses: papeloto/action-zip@v1
with:
files: ./OpenDirectoryDownloader-linux-arm64
dest: OpenDirectoryDownloader-linux-arm64.zip

- name: Publish with dotnet linux-arm64 (self-contained)
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime linux-arm64 --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:IncludeNativeLibrariesForSelfExtract=true --output ./OpenDirectoryDownloader-linux-arm64-self-contained

- name: Zipping linux-arm64 (self-contained)
uses: papeloto/action-zip@v1
with:
files: ./OpenDirectoryDownloader-linux-arm64-self-contained
dest: OpenDirectoryDownloader-linux-arm64-self-contained.zip



- name: Publish with dotnet linux-arm
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime linux-arm --no-self-contained -p:PublishSingleFile=true --output ./OpenDirectoryDownloader-linux-arm

- name: Zipping linux-arm
uses: papeloto/action-zip@v1
with:
files: ./OpenDirectoryDownloader-linux-arm
dest: OpenDirectoryDownloader-linux-arm.zip

- name: Publish with dotnet linux-arm (self-contained)
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime linux-arm --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:IncludeNativeLibrariesForSelfExtract=true --output ./OpenDirectoryDownloader-linux-arm-self-contained

- name: Zipping linux-arm (self-contained)
uses: papeloto/action-zip@v1
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
files: ./OpenDirectoryDownloader-linux-arm-self-contained
dest: OpenDirectoryDownloader-linux-arm-self-contained.zip



- name: Publish with dotnet osx-x64
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime osx-x64 --no-self-contained -p:PublishSingleFile=true --output ./OpenDirectoryDownloader-osx-x64
name: all-artifacts
path: |
OpenDirectoryDownloader-${{ matrix.target }}${{ matrix.suffix }}.zip
- name: Zipping osx-x64
uses: papeloto/action-zip@v1
with:
files: ./OpenDirectoryDownloader-osx-x64
dest: OpenDirectoryDownloader-osx-x64.zip
- name: Publish with dotnet osx-x64 (self-contained)
run: dotnet publish OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net5.0 --runtime osx-x64 --self-contained=true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:IncludeNativeLibrariesForSelfExtract=true --output ./OpenDirectoryDownloader-osx-x64-self-contained
release:
needs: build
runs-on: ubuntu-latest

- name: Zipping osx-x64 (self-contained)
uses: papeloto/action-zip@v1
steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
files: ./OpenDirectoryDownloader-osx-x64-self-contained
dest: OpenDirectoryDownloader-osx-x64-self-contained.zip


name: all-artifacts

- name: Get tag info
id: tag_info
run: echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}
- name: Create release
id: create_release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: OpenDirectoryDownloader ${{ github.ref }}
tag_name: ${{ steps.tag_info.outputs.SOURCE_TAG }}
name: OpenDirectoryDownloader ${{ steps.tag_info.outputs.SOURCE_TAG }}
draft: false
prerelease: false
body: ${{ github.event.head_commit.message }}



- name: Upload Release Asset win-x64
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-win-x64.zip
asset_name: OpenDirectoryDownloader-win-x64.zip
asset_content_type: application/zip

- name: Upload Release Asset win-x64 (self-contained)
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-win-x64-self-contained.zip
asset_name: OpenDirectoryDownloader-win-x64-self-contained.zip
asset_content_type: application/zip



- name: Upload Release Asset linux-x64
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-linux-x64.zip
asset_name: OpenDirectoryDownloader-linux-x64.zip
asset_content_type: application/zip

- name: Upload Release Asset linux-x64 (self-contained)
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-linux-x64-self-contained.zip
asset_name: OpenDirectoryDownloader-linux-x64-self-contained.zip
asset_content_type: application/zip



- name: Upload Release Asset linux-arm64
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-linux-arm64.zip
asset_name: OpenDirectoryDownloader-linux-arm64.zip
asset_content_type: application/zip

- name: Upload Release Asset linux-arm64 (self-contained)
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-linux-arm64-self-contained.zip
asset_name: OpenDirectoryDownloader-linux-arm64-self-contained.zip
asset_content_type: application/zip



- name: Upload Release Asset linux-arm
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-linux-arm.zip
asset_name: OpenDirectoryDownloader-linux-arm.zip
asset_content_type: application/zip

- name: Upload Release Asset linux-arm (self-contained)
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-linux-arm-self-contained.zip
asset_name: OpenDirectoryDownloader-linux-arm-self-contained.zip
asset_content_type: application/zip



- name: Upload Release Asset osx-x64
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-osx-x64.zip
asset_name: OpenDirectoryDownloader-osx-x64.zip
asset_content_type: application/zip

- name: Upload Release Asset osx-x64 (self-contained)
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OpenDirectoryDownloader-osx-x64-self-contained.zip
asset_name: OpenDirectoryDownloader-osx-x64-self-contained.zip
asset_content_type: application/zip
files: |
OpenDirectoryDownloader-*.zip

docker:
needs: build
Expand Down

0 comments on commit 465af36

Please sign in to comment.