aboutsummaryrefslogtreecommitdiffstats
path: root/.github/workflows/ci.yml
blob: 2960b190d951ecff7005ae93e22a339036f275f6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: CI
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  workflow_dispatch:

jobs:
  build:
    name: Build and Test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set Environment Variables
        run: |
          echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
          echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
      - name: Web
        run: ./bin/build --web-only
      - name: Dotnet
        run: ./bin/build --dotnet-only --version ${{ env.LATEST_TAG }}-${{ env.SHORT_SHA }}
      - name: Upload Static Web Content
        uses: actions/upload-artifact@v2
        with:
          name: web
          path: src/web/build
  publish:
    name: Publish Build Artifacts
    runs-on: ubuntu-latest
    needs: build
    if: github.ref == 'refs/heads/master'
    strategy:
      matrix:
        runtime: ["win-x64", "linux-x64", "linux-musl-x64", "linux-arm64", "osx-x64"]
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set Environment Variables
        run: |
          echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
          echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
      - uses: actions/download-artifact@v2
        with:
          name: web
          path: src/slskd/wwwroot
      - name: Publish ${{ matrix.runtime }}
        run: bin/publish --no-prebuild --runtime ${{ matrix.runtime }} --version ${{ env.LATEST_TAG }}-${{ env.SHORT_SHA }}
      - name: Upload a Build Artifact
        uses: actions/upload-artifact@v2
        with:
          name: slskd-${{ env.LATEST_TAG }}.${{ env.SHORT_SHA }}-${{ matrix.runtime }}
          path: dist/${{ matrix.runtime }}
  docker:
    name: Build Docker Image
    runs-on: ubuntu-latest
    needs: build
    if: github.ref == 'refs/heads/master'
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Set Environment Variables
        run: |
          echo "LATEST_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
          echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
      - name: Build
        run: docker build -t slskd/slskd:${{ env.LATEST_TAG }}.${{ env.SHORT_SHA }} --build-arg VERSION=${{ env.LATEST_TAG }} --build-arg SHA=${{ env.SHORT_SHA }} .
      - name: Tag (Nightly)
        run: docker tag slskd/slskd:${{ env.LATEST_TAG }}.${{ env.SHORT_SHA }} slskd/slskd:nightly
      - name: Login
        run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
      - name: Push
        run: |
          docker push slskd/slskd:${{ env.LATEST_TAG }}.${{ env.SHORT_SHA }}
          docker push slskd/slskd:nightly