name: CI on: push: branches: [ master ] tags: "[0-9]+.[0-9]+.[0-9]+" pull_request: branches: [ master ] workflow_dispatch: jobs: build: name: Build and Test runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Set Environment Variables run: | echo "VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Web run: ./bin/build --web-only - name: Dotnet run: ./bin/build --dotnet-only --version ${{ env.VERSION }} - name: Upload Static Web Content if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') uses: actions/upload-artifact@v2 with: name: web-${{ env.VERSION }} path: src/web/build publish: name: Publish runs-on: ubuntu-latest needs: build if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') strategy: matrix: runtime: ["win-x64", "linux-x64", "linux-arm", "linux-arm64", "osx-x64"] steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Set Environment Variables run: | echo "VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Download Static Web Content uses: actions/download-artifact@v2 with: name: web-${{ env.VERSION }} path: src/slskd/wwwroot - name: Build ${{ matrix.runtime }} run: bin/publish --no-prebuild --runtime ${{ matrix.runtime }} --version ${{ env.VERSION }} - name: Upload Binaries uses: actions/upload-artifact@v2 with: name: slskd-${{ env.VERSION }}-${{ matrix.runtime }} path: dist/${{ matrix.runtime }} docker: name: Build Docker Image runs-on: ubuntu-latest needs: build if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Set Environment Variables run: | echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV echo "VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV echo "REVISION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV echo "BUILD_DATE=$(date --iso-8601=s)" >> $GITHUB_ENV - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Cache Docker layers uses: actions/cache@v2 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ secrets.GHCR_USERNAME }} password: ${{ secrets.GHCR_PAT }} - name: Build and push Canary if: "!startsWith(github.ref, 'refs/tags/')" uses: docker/build-push-action@v2 with: platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true build-args: | TAG=${{ env.TAG }} VERSION=${{ env.VERSION }} REVISION=${{ env.REVISION }} BUILD_DATE=${{ env.BUILD_DATE }} tags: | slskd/slskd:${{ env.VERSION }} slskd/slskd:canary ghcr.io/slskd/slskd:${{ env.VERSION }} ghcr.io/slskd/slskd:canary cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - name: Build and push Release if: startsWith(github.ref, 'refs/tags/') uses: docker/build-push-action@v2 with: platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true build-args: | VERSION=${{ env.VERSION }} tags: | slskd/slskd:${{ env.VERSION }} slskd/slskd:${{ env.TAG }} slskd/slskd:canary slskd/slskd:latest ghcr.io/slskd/slskd:${{ env.VERSION }} ghcr.io/slskd/slskd:${{ env.TAG }} ghcr.io/slskd/slskd:canary ghcr.io/slskd/slskd:latest cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache release: name: Create Release runs-on: ubuntu-latest needs: [publish, docker] if: startsWith(github.ref, 'refs/tags/') steps: - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - name: Set Environment Variables run: | echo "TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV echo "VERSION=$(git describe --tags --abbrev=0).$([[ $GITHUB_REF = refs/tags/* ]] && echo 0 || echo 65534)-$(git rev-parse --short HEAD)" >> $GITHUB_ENV - name: Download win-x64 Binaries uses: actions/download-artifact@v2 with: name: slskd-${{ env.VERSION }}-win-x64 path: dist/win-x64 - name: Zip win-x64 Binaries run: | cd dist/win-x64 zip -r ../../slskd-${{ env.TAG }}-win-x64.zip . - name: Download linux-x64 Binaries uses: actions/download-artifact@v2 with: name: slskd-${{ env.VERSION }}-linux-x64 path: dist/linux-x64 - name: Zip linux-x64 Binaries run: | cd dist/linux-x64 zip -r ../../slskd-${{ env.TAG }}-linux-x64.zip . - name: Download linux-arm Binaries uses: actions/download-artifact@v2 with: name: slskd-${{ env.VERSION }}-linux-arm path: dist/linux-arm - name: Zip linux-arm Binaries run: | cd dist/linux-arm zip -r ../../slskd-${{ env.TAG }}-linux-arm.zip . - name: Download linux-arm64 Binaries uses: actions/download-artifact@v2 with: name: slskd-${{ env.VERSION }}-linux-arm64 path: dist/linux-arm64 - name: Zip linux-arm64 Binaries run: | cd dist/linux-arm64 zip -r ../../slskd-${{ env.TAG }}-linux-arm64.zip . - name: Download osx-x64 Binaries uses: actions/download-artifact@v2 with: name: slskd-${{ env.VERSION }}-osx-x64 path: dist/osx-x64 - name: Zip osx-x64 Binaries run: | cd dist/osx-x64 zip -r ../../slskd-${{ env.TAG }}-osx-x64.zip . - name: Build Changelog id: build_changelog uses: mikepenz/release-changelog-builder-action@v1.4.0 with: configuration: .github/configuration/changelog.json env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create Release uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: body: ${{ steps.build_changelog.outputs.changelog }} files: | slskd-${{ env.TAG }}-win-x64.zip slskd-${{ env.TAG }}-linux-x64.zip slskd-${{ env.TAG }}-linux-arm.zip slskd-${{ env.TAG }}-linux-arm64.zip slskd-${{ env.TAG }}-osx-x64.zip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}