aboutsummaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/release.yml
blob: 7ea2802158dd8889144bc8657b291c6e53c92e48 (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
135
136
137
name: release
on:
  schedule:
    - cron: "0 4 * * *"
  workflow_dispatch:
    inputs:
      target:
        description: Make target
        default: release
        type: choice
        options:
          - release
      nightly:
        description: Nightly build
        type: boolean
      debug:
        description: Debug symbols
        type: boolean
      tag:
        description: Optional release tag (normally auto-detected)

jobs:
  build:
    runs-on: ubuntu-20.04
    container: ghcr.io/orbitalquark/textadept-build:v2.0
    outputs:
      version: ${{ steps.build.outputs.version }}
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Checkout textadept-build dependencies
        uses: actions/checkout@v2
        with:
          repository: orbitalquark/textadept-build
          path: textadept-build
      - name: Build
        id: build
        shell: bash
        run: |
          # Move cached dependencies into src/.
          mv textadept-build/* src && rm -r textadept-build

          # Build.
          if [[ ${{ github.event_name }} != schedule ]]; then
            target="${{ github.event.inputs.target }}"
            if [[ ${{ github.event.inputs.nightly }} = true ]]; then nightly="NIGHTLY=1"; fi
            if [[ ${{ github.event.inputs.debug }} = true ]]; then debug="DEBUG=1"; fi
          else
            target="release"
            nightly="NIGHTLY=1"
            debug="DEBUG=1"
          fi
          make -C src deps win-deps osx-deps $nightly
          make -C src $target $debug $nightly

          # For nightly builds, strip the date from filenames.
          for file in `ls src/textadept_nightly* 2>/dev/null`; do
            mv $file `echo $file | sed 's/_[0-9]\{4\}\(-[0-9]\{2\}\)\{2\}//;'`
          done

          # Output version information for use in later steps.
          version="${{ github.event.inputs.tag }}"
          if [[ -z $version ]]; then
            version=`ls -1 src/textadept_*.zip | head -1 | sed 's/[^_]\+_\(.\+\)\.[^.]\+\.zip/\1/;'`
          fi
          echo "::set-output name=version::$version"
      - name: Package modules
        shell: bash
        run: |
          mkdir textadept-modules
          modules="css ctags debugger export file_diff format html lsp lua_repl open_file_mode \
            python rest ruby spellcheck yaml"
          for module in $modules; do
            gh_name="`echo -n $module | sed -e 's/_/-/g;'`"
            gh_prefix="https://github.com/orbitalquark/textadept-$gh_name"
            wget $gh_prefix/releases/download/latest/$module.zip
            unzip -d textadept-modules $module.zip
          done
          zip -r src/textadept_${{ steps.build.outputs.version }}.modules.zip textadept-modules
      - name: Upload artifacts
        uses: actions/upload-artifact@v2
        with:
          name: artifacts
          path: |
            src/textadept_*
            docs/changelog.md
  tag:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Tag
        run: |
          git tag textadept_${{ needs.build.outputs.version }}
          git push -f origin textadept_${{ needs.build.outputs.version }}
  release:
    runs-on: ubuntu-latest
    needs: [build, tag]
    steps:
      - name: Download artifacts
        uses: actions/download-artifact@v2
        with:
          name: artifacts
      - name: Create release log
        shell: bash
        run: |
          echo -n "Textadept " > log.md
          echo -n "${{ needs.build.outputs.version }} " | tr '_' ' ' >> log.md
          echo \(`date +"%d %b %Y"`\) >> log.md
          if [[ ${{ needs.build.outputs.version }} = nightly ]]; then exit 0; fi
          prefix="https://orbitalquark.github.io/textadept"
          echoing=0
          while read line; do
            if [[ $line == \#\#\#* ]]; then
              if [[ $echoing -eq 0 ]]; then
                echoing=1
              else
                exit 0
              fi
            elif [[ $echoing -eq 1 ]]; then
              echo "$line" | sed "s,\(manual\|api\)\.html,$prefix/\0,;"
            fi
          done < docs/changelog.md >> log.md
      - name: Create release
        uses: ncipollo/release-action@v1
        with:
          name: ${{ needs.build.outputs.version }}
          tag: textadept_${{ needs.build.outputs.version }}
          prerelease: |
            ${{ needs.build.outputs.version == 'nightly' ||
              contains(needs.build.outputs.version, 'alpha') ||
              contains(needs.build.outputs.version, 'beta') }}
          allowUpdates: true
          bodyFile: log.md
          artifacts: src/textadept_*
          token: ${{ secrets.GITHUB_TOKEN }}