aboutsummaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/release.yml
blob: 7666d61543b401803be79396d56a00554199f77f (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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:
  macports-cache:
    runs-on: macos-12

    steps:
    - uses: actions/checkout@v2

    - name: "Install gtar wrapper"
      run: |
        sudo mv /usr/local/bin/gtar /usr/local/bin/gtar.orig
        sudo cp macosx/gtar /usr/local/bin/gtar
        sudo chmod +x /usr/local/bin/gtar

    - name: Cache macports
      id: cache-macports
      uses: actions/cache@v3
      env:
        cache-name: cache-macports
      with:
        path: /opt/local
        key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('macosx/port-deps.sh') }}
        restore-keys: |
          ${{ runner.os }}-build-${{ env.cache-name }}-
          ${{ runner.os }}-build-
          ${{ runner.os }}-

    - name: "setup MacPorts environment"
      run: |
        curl -L "https://github.com/macports/macports-base/releases/download/v2.7.2/MacPorts-2.7.2-12-Monterey.pkg" --output macports.pkg
        sudo installer -pkg macports.pkg -target /
        ./macosx/port-deps.sh deps

  release:
    needs: macports-cache
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-22.04, macos-12]

    steps:
    - uses: actions/checkout@v2

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

    - 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: "Install gtar wrapper"
      if: ${{ startsWith(matrix.os, 'macos') }}
      run: |
        sudo mv /usr/local/bin/gtar /usr/local/bin/gtar.orig
        sudo cp macosx/gtar /usr/local/bin/gtar
        sudo chmod +x /usr/local/bin/gtar

    - name: Restore macports cache
      id: cache-macports
      if: ${{ startsWith(matrix.os, 'macos') }}
      uses: actions/cache@v3
      env:
        cache-name: cache-macports
      with:
        path: /opt/local
        key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('macosx/port-deps.sh') }}
        restore-keys: |
          ${{ runner.os }}-build-${{ env.cache-name }}-
          ${{ runner.os }}-build-
          ${{ runner.os }}-

    - 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 &&
        ../port-deps.sh describe &&
        ../osx-xcode.sh describe &&
        tar -cjf "../${BUILD_TAG}-osx-build-report.tbz" . &&
        popd

    - name: "generate build scripts"
      run: PATH=/opt/local/bin:$PATH ./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 -f

    - name: "macOS package build"
      if: ${{ startsWith(matrix.os, 'macos') }}
      run: |
        pushd macosx &&
        env ZERO_AR_DATE=1 MACOSX_DEPLOYMENT_TARGET=11.0 PATH=/opt/local/bin:$PATH ./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