blob: 12226f9110e02797c0138bdee1e35f83cf88aaca (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
name: release

on:
  push:
    tags:
      - 'v*'

# Needed to create the draft release.
permissions:
  contents: write

jobs:
  draft-release:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v7
        with:
          submodules: recursive
          # Tags let git describe stamp the exact release version into
          # the binary rather than the Makefile fallback.
          fetch-tags: true
          fetch-depth: 0
      - name: Install build dependencies
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential zlib1g-dev gettext libtool libluajit-5.1-dev
      # Build two hardened variants: a self-contained one with no Lua, and one
      # that links the lua: filter backend. Each is packaged with a checksum.
      - name: Build and package both variants
        run: |
          package() {   # $1 = release-build.sh arg, $2 = tarball suffix
            ./tools/release-build.sh $1
            dist="cgit-${GITHUB_REF_NAME}${2}"
            mkdir -p "$dist"
            cp build/cgit "$dist/cgit.cgi"
            cp assets/cgit.css assets/cgit.js assets/cgit.png assets/favicon.ico assets/robots.txt "$dist/"
            cp cgitrc.5.txt README.txt LICENSE.txt AUTHORS "$dist/"
            # Ship the filter scripts and the example configs, hooks and
            # server setups that the docs and cgitrc reference.
            cp -r extensions examples "$dist/"
            tar czf "${dist}.tar.gz" "$dist"
            sha256sum "${dist}.tar.gz" > "${dist}.tar.gz.sha256"
          }
          package "" ""
          package "lua" "-lua"
      # Creates a DRAFT release only. Review and publish it by hand.
      - name: Create draft release
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          gh release create "${GITHUB_REF_NAME}" \
            --draft \
            --title "cgit ${GITHUB_REF_NAME}" \
            --generate-notes \
            "cgit-${GITHUB_REF_NAME}.tar.gz" \
            "cgit-${GITHUB_REF_NAME}.tar.gz.sha256" \
            "cgit-${GITHUB_REF_NAME}-lua.tar.gz" \
            "cgit-${GITHUB_REF_NAME}-lua.tar.gz.sha256"