- Add merge, maybe needed for docker steps #270
Workflow file for this run
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: Continuous Integration | |
on: | |
push: | |
# Sequence of patterns matched against refs/tags | |
tags: | |
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
build: | |
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 -p:PublishTrimmed=true -p:TrimMode=partial -p:EnableCompressionInSingleFile=true | |
suffix: "-self-contained" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '8.0.x' | |
include-prerelease: true | |
- name: Get version info | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
- name: Restore with dotnet | |
run: dotnet restore src/OpenDirectoryDownloader | |
- name: Build with dotnet | |
run: dotnet build src/OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} | |
- name: Test with dotnet | |
run: dotnet test src/OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} | |
- name: Publish with dotnet | |
run: dotnet publish src/OpenDirectoryDownloader --configuration Release -p:Version=${{ steps.get_version.outputs.VERSION }} --framework net8.0 --runtime ${{ matrix.target }} ${{ matrix.build_args }} -p:PublishSingleFile=true --output ./OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }} | |
- name: Set executable bit (linux only) | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: | | |
chmod +x ./OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }}/OpenDirectoryDownloader | |
- name: Zipping | |
run: | | |
7z a OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }}.zip ./OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }}/* | |
# 7z is installed in all environments and supports unix permissions while compressing (but not while decompressing!) | |
- name: Upload artifact for docker job (linux only) | |
if: ${{ matrix.os == 'ubuntu-latest' && matrix.self-contained == 'normal' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifact-${{ matrix.target }}${{ matrix.suffix }} | |
path: | | |
OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }}.zip | |
src/Dockerfile | |
overwrite: true | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-artifact-${{ matrix.target }}${{ matrix.suffix }} | |
path: | | |
OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}${{ matrix.suffix }}.zip | |
overwrite: true | |
merge: | |
runs-on: ubuntu-latest | |
needs: [ build ] | |
steps: | |
- name: Merge Artifacts | |
uses: actions/upload-artifact/merge@v4 | |
with: | |
name: build-artifact | |
pattern: build-artifact-* | |
release: | |
needs: [ merge ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: build-artifact | |
pattern: build-artifact-* | |
merge-multiple: true | |
- name: Get tag info | |
id: tag_info | |
run: echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
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 }} | |
files: | | |
OpenDirectoryDownloader-*.zip | |
docker: | |
needs: build | |
strategy: | |
matrix: | |
target: | |
- linux-x64 | |
- linux-arm | |
- linux-arm64 | |
include: | |
- target: linux-x64 | |
platform: linux/amd64 | |
- target: linux-arm | |
platform: linux/arm/v7 | |
- target: linux-arm64 | |
platform: linux/arm64 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get version info | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifact-${{ matrix.target }}${{ matrix.suffix }} | |
- name: Decompress artifact | |
uses: TonyBogdanov/zip@1.0 | |
with: | |
args: unzip -qq ./OpenDirectoryDownloader-${{ steps.get_version.outputs.VERSION }}-${{ matrix.target }}.zip -d ./app | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./src/Dockerfile | |
platforms: ${{ matrix.platform }} | |
push: true | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:${{ matrix.target }} | |
combine: | |
needs: docker | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Get tag info | |
id: tag_info | |
run: echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Combine images | |
run: > | |
docker buildx imagetools create | |
-t ${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:latest | |
-t ${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:${{ steps.tag_info.outputs.SOURCE_TAG }} | |
${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:linux-x64 | |
${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:linux-arm | |
${{ secrets.DOCKERHUB_USERNAME }}/opendirectorydownloader:linux-arm64 | |