aboutsummaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/release.yml
blob: 0aa23e55732241855194cbd3954d471b1e62e6b2 (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
name: Release

on:
  push:
    tags:
      # This syntax is globs, not regex, so it's matching any tag that
      # contains the prefix "mosh-" and the 3 version elements.
      - "mosh-*.*.*"

jobs:
  release:
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-20.04, macos-latest]

    steps:
    - uses: actions/checkout@v2

    - name: "ensure version bumped"
      run: |
        expected_tag=$(echo ${{ github.ref }} | cut -d'/' -f3)
        have_tag=$(sed -n 's/AC_INIT(\[[^]]*\], \[\([^]]*\)\].*/\1/p' <configure.ac)
        echo "Expected tag <$expected_tag>, got <$have_tag>"
        [[ "$expected_tag" != "$have_tag" ]] && exit 1

    - name: "setup linux build environment"
      if: ${{ startsWith(matrix.os, 'ubuntu') }}
      run: sudo apt install -y protobuf-compiler libprotobuf-dev libutempter-dev autoconf automake nettle-dev

    - name: "setup macos build environment"
      if: ${{ startsWith(matrix.os, 'macos') }}
      run: brew install protobuf automake

    - name: "describe macos build environment"
      if: ${{ startsWith(matrix.os, 'macos') }}
      run: |
        BUILD_TAG=$(echo ${{ github.ref }} | cut -d'/' -f3)
        mkdir macosx/build-report &&
        pushd macosx/build-report &&
        ../brew-deps.sh describe &&
        ../osx-xcode.sh describe &&
        tar -cjf "../${BUILD_TAG}-osx-build-report.tbz" . &&
        popd

    - name: "generate build scripts"
      run: ./autogen.sh

    - name: "configure"
      if: ${{ startsWith(matrix.os, 'ubuntu') }}
      run: ./configure --enable-compile-warnings=error --enable-examples

    - name: "build"
      if: ${{ startsWith(matrix.os, 'ubuntu') }}
      run: make V=1

    - name: "test"
      if: ${{ startsWith(matrix.os, 'ubuntu') }}
      run: make V=1 distcheck -j
    
    - name: "unshallow git repository for git describe"
      if: ${{ startsWith(matrix.os, 'macos') }}     
      run: git fetch --tags --unshallow
      
    - name: "macOS package build"
      if: ${{ startsWith(matrix.os, 'macos') }}
      run: |
        pushd macosx &&
        env ZERO_AR_DATE=1 MACOSX_DEPLOYMENT_TARGET=10.12 ./build.sh &&
        popd

    - name: "Upload Release"
      # v1 aka v0.1.14 as of 2022-07-05; pinned to avoid potential code injection
      uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5
      with:
        # Action always creates releases in "draft" mode, and requires
        # a maintainer to publish them
        draft: True
        prerelease: contains(github.ref, 'rc')
        generate_release_notes: True
        files: |
          mosh-*.tar.gz
          macosx/*.pkg
          macosx/*-osx-build-report.tbz