aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: 18702edbc88b6b23933f9804884f7ab43a9294e8 (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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Release

on:
  push:
    tags:
      - '*'

jobs:
  deb:
    if: true
    runs-on: ubuntu-latest
    container:
      image: debian:bookworm
    env:
      BUILD_TYPE: Release

    steps:
      - uses: actions/checkout@v4

      - name: Install dependencies
        run: apt-get -y update && apt-get install -y build-essential cmake

      - name: Cmake
        run: cmake -B build -D BUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE

      - name: Build
        run: cmake --build build --config $BUILD_TYPE

      - name: Package
        id: package
        working-directory: build
        run: |
          cpack -G "DEB" -D CPACK_PACKAGE_FILE_NAME=libstorm-dev_${{ github.ref_name }}_amd64

      - uses: actions/upload-artifact@v4
        with:
          retention-days: 1
          overwrite: true
          name: libstorm-dev_${{ github.ref_name }}_amd64.deb
          path: build/libstorm-dev_${{ github.ref_name }}_amd64.deb

  rpm:
    if: true
    runs-on: ubuntu-latest
    container:
      image: fedora:latest
    env:
      BUILD_TYPE: Release

    steps:
      - uses: actions/checkout@v4

      - name: Install dependencies
        run: dnf -y install cmake gcc gcc-c++ rpm-build

      - name: Cmake
        run: cmake -B build -D BUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=$BUILD_TYPE

      - name: Build
        run: cmake --build build --config $BUILD_TYPE

      - name: Package
        working-directory: build
        run: cpack -G "RPM" -D CPACK_PACKAGE_FILE_NAME=libstorm-devel-${{ github.ref_name }}.x86_64

      - uses: actions/upload-artifact@v4
        with:
          retention-days: 1
          overwrite: true
          name: libstorm-devel-${{ github.ref_name }}.x86_64.rpm
          path: build/libstorm-devel-${{ github.ref_name }}.x86_64.rpm

  build_win:
    if: true
    runs-on: windows-latest
    strategy:
      matrix:
        arch: [ amd64, x86 ]
        build_type: [ Release, Debug ]
        unicode: [ ON, OFF ]
        shared: [ ON, OFF ]

    steps:
      - uses: actions/checkout@v4

      - uses: TheMrMilchmann/setup-msvc-dev@v3
        with:
          arch: ${{ matrix.arch }}

      - name: Configure CMake for amd64
        if: ${{ matrix.arch == 'amd64' }}
        shell: cmd
        run: cmake -B build -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DSTORM_UNICODE=${{ matrix.unicode }}

      - name: Configure CMake for x86
        if: ${{ matrix.arch == 'x86' }}
        shell: cmd
        run: cmake -B build -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DSTORM_UNICODE=${{ matrix.unicode }} -A Win32

      - name: Build
        shell: cmd
        run: cmake --build build --config ${{ matrix.build_type }}

      - name: Check PE
        if: ${{ matrix.shared == 'ON' }}
        shell: bash
        working-directory: ./build/${{ matrix.build_type }}
        run: |
          file "stormlib.dll"
          if [[ "${{ matrix.arch }}" == "x86" ]]; then
            file "stormlib.dll" | grep -E "Intel 80386|Intel i386"
          else
            file "stormlib.dll" | grep "x86-64"
          fi

      - name: Install to staging area
        shell: cmd
        run: cmake --install build --prefix build/staging --config ${{ matrix.build_type }}

      - name: Create Archive
        shell: pwsh
        id: create_archive
        working-directory: ./build/staging
        run: |
          $r = if ("${{ matrix.build_type }}" -eq "Release") { "R" } else { "D" }
          $a = if ("${{ matrix.unicode }}" -eq "ON") { "U" } else { "A" }
          $s = if ("${{ matrix.shared }}" -eq "ON") { "D" } else { "S" }
      
          $zipSuffix = "${r}${a}${s}"
          $zipName = "stormlib_${{ github.ref_name }}_${{ matrix.arch }}_${zipSuffix}.zip"
          "zip_name=$zipName" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
          
          Compress-Archive -Path include -DestinationPath $zipName
          
          $binItems = Get-ChildItem -Path bin\* -ErrorAction SilentlyContinue
          if ($binItems) {
            Compress-Archive -Path bin/* -DestinationPath $zipName -Update
          }
          $libItems = Get-ChildItem -Path lib\* -ErrorAction SilentlyContinue
          if ($libItems) {
            Compress-Archive -Path "lib/*" -DestinationPath $zipName -Update
          }
      - uses: actions/upload-artifact@v4
        with:
          retention-days: 1
          overwrite: true
          name: ${{ steps.create_archive.outputs.zip_name }}
          path: build/staging/${{ steps.create_archive.outputs.zip_name }}

  release:
    needs: [deb, rpm, build_win]
    runs-on: ubuntu-latest

    steps:
      - name: Download deb
        uses: actions/download-artifact@v4
        with:
          name: libstorm-dev_${{ github.ref_name }}_amd64.deb

      - name: Download rpm
        uses: actions/download-artifact@v4
        with:
          name: libstorm-devel-${{ github.ref_name }}.x86_64.rpm

      - name: Download win
        uses: actions/download-artifact@v4
        with:
          pattern: "*.zip"
          merge-multiple: true

      - name: Generate SHA256 checksums
        run: |
          for file in *.zip *.deb *.rpm; do
            sha256sum "$file" >> "release.sha256"
          done

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v1
        with:
          files: |
            *.deb
            *.sha256
            *.rpm
            *.zip
          tag_name: ${{ github.ref_name }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}