aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: d889a058b61485695181d469c9d39f716793524e (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: CI

on:
  push:
    branches: [main]
    tags: ['v*']
  pull_request:
  workflow_dispatch:

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ghcr.io/sulfurnitride/fluorine-builder

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Log in to GHCR
        uses: docker/login-action@v3
        with:
          registry: ${{ env.REGISTRY }}
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build Docker image
        uses: docker/build-push-action@v6
        with:
          context: docker
          file: docker/Dockerfile
          load: true
          tags: fluorine-builder:latest
          cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache
          cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max

      - name: Build inside container
        run: |
          docker run --rm \
            -v "${{ github.workspace }}:/src:rw" \
            -w /src \
            fluorine-builder:latest \
            bash /src/docker/build-inner.sh

      - name: Collect artifacts
        run: |
          mkdir -p artifact
          if ls build/*.AppImage >/dev/null 2>&1; then
            cp build/*.AppImage artifact/
          fi
          if [ -d build/staging ]; then
            tar -czf artifact/fluorine-staging.tar.gz -C build/staging .
          fi
          ls -lh artifact/

      - name: Upload AppImage
        uses: actions/upload-artifact@v4
        with:
          name: Fluorine-AppImage
          path: artifact/*.AppImage
          if-no-files-found: warn

      - name: Upload staging
        uses: actions/upload-artifact@v4
        with:
          name: Fluorine-Staging
          path: artifact/fluorine-staging.tar.gz
          if-no-files-found: warn

  release:
    if: startsWith(github.ref, 'refs/tags/v')
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: write

    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v4
        with:
          name: Fluorine-AppImage
          path: artifact/

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: artifact/*.AppImage
          generate_release_notes: true