Skip to content

Commit a9337e6

Browse files
authored
Merge pull request #4321 from Cyan4973/win_artifacts
Automate Windows Artifact generation and publication
2 parents 017ada4 + e99be47 commit a9337e6

File tree

2 files changed

+58
-36
lines changed

2 files changed

+58
-36
lines changed

.github/workflows/windows-artifacts.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: windows-artifacts
22

33
on:
44
push:
5-
branches: [ test_artifacts, win_artifacts ]
5+
branches: [ test_artifacts, win_artifacts, release ]
66
release:
77
types:
88
- published
@@ -11,6 +11,8 @@ permissions: read-all
1111

1212
jobs:
1313
windows-artifacts:
14+
permissions:
15+
contents: write # to fetch code and upload artifacts
1416
# see https://ariya.io/2020/07/on-github-actions-with-msys2
1517
runs-on: windows-latest
1618
# see https://github.com/msys2/setup-msys2
@@ -27,7 +29,7 @@ jobs:
2729
- uses: msys2/setup-msys2@61f9e5e925871ba6c9e3e8da24ede83ea27fa91f # tag=v2.27.0
2830
with:
2931
msystem: ${{ matrix.msystem }}
30-
install: make zlib git p7zip mingw-w64-${{matrix.env}}-gcc
32+
install: make zlib p7zip git mingw-w64-${{matrix.env}}-gcc
3133
update: true
3234

3335
- name: display versions
@@ -37,22 +39,36 @@ jobs:
3739
3840
- name: Building zlib to static link
3941
run: |
40-
git clone --depth 1 --branch v1.2.11 https://github.com/madler/zlib
42+
git clone --depth 1 --branch v1.3.1 https://github.com/madler/zlib
4143
make -C zlib -f win32/Makefile.gcc libz.a
4244
4345
- name: Building zstd programs
4446
run: |
45-
CPPFLAGS=-I../zlib LDFLAGS=../zlib/libz.a make -j allzstd MOREFLAGS=-static V=1
47+
CPPFLAGS=-I../zlib LDLIBS=../zlib/libz.a LDFLAGS=-static make -j allzstd V=1
4648
4749
- name: Create artifacts
4850
run: |
4951
./lib/dll/example/build_package.bat || exit 1
5052
mv bin/ zstd-${{ github.ref_name }}-${{matrix.ziparch}}/
51-
7z a -tzip -mx9 zstd-${{ github.ref_name }}-${{matrix.ziparch}}.zip zstd-${{ github.ref_name }}-${{matrix.ziparch}}/
52-
cd ..
5353
54-
- name: Publish zstd-$VERSION-${{matrix.ziparch}}.zip
54+
- name: Publish zstd-$VERSION-${{matrix.ziparch}}.zip for manual inspection
5555
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # tag=v4.3.1
5656
with:
57-
path: ${{ github.workspace }}/zstd-${{ github.ref_name }}-${{matrix.ziparch}}.zip
58-
name: zstd-${{ github.ref_name }}-${{matrix.ziparch}}.zip
57+
compression-level: 9 # maximum compression
58+
if-no-files-found: error # defaults to `warn`
59+
path: ${{ github.workspace }}/zstd-${{ github.ref_name }}-${{matrix.ziparch}}/
60+
name: zstd-${{ github.ref_name }}-${{matrix.ziparch}}
61+
62+
- name: Package artifact for upload
63+
run: |
64+
7z a -tzip -mx9 "$(cygpath -u '${{ github.workspace }}/zstd-${{ github.ref_name }}-${{ matrix.ziparch }}.zip')" "$(cygpath -u '${{ github.workspace }}/zstd-${{ github.ref_name }}-${{ matrix.ziparch }}')"
65+
66+
- name: Upload release asset
67+
if: github.event_name == 'release'
68+
shell: pwsh
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
gh release upload "${{ github.ref_name }}" "$env:GITHUB_WORKSPACE/zstd-${{ github.ref_name }}-${{ matrix.ziparch }}.zip" --clobber
73+
74+

lib/dll/example/build_package.bat

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
1-
@ECHO OFF
2-
MKDIR bin\dll bin\static bin\example bin\include
3-
SET CpyError=
4-
COPY tests\fullbench.c bin\example\ || (SET CpyError=%CpyError% tests\fullbench.c)
5-
COPY programs\datagen.c bin\example\ || (SET CpyError=%CpyError% programs\datagen.c)
6-
COPY programs\datagen.h bin\example\ || (SET CpyError=%CpyError% programs\datagen.h)
7-
COPY programs\util.h bin\example\ || (SET CpyError=%CpyError% programs\util.h)
8-
COPY programs\platform.h bin\example\ || (SET CpyError=%CpyError% programs\platform.h)
9-
COPY lib\common\mem.h bin\example\ || (SET CpyError=%CpyError% lib\common\mem.h)
10-
COPY lib\common\zstd_internal.h bin\example\ || (SET CpyError=%CpyError% lib\common\zstd_internal.h)
11-
COPY lib\common\error_private.h bin\example\ || (SET CpyError=%CpyError% lib\common\error_private.h)
12-
COPY lib\common\xxhash.h bin\example\ || (SET CpyError=%CpyError% lib\common\xxhash.h)
13-
COPY lib\libzstd.a bin\static\libzstd_static.lib || (SET CpyError=%CpyError% lib\libzstd.a)
14-
COPY lib\dll\libzstd.* bin\dll\ || (SET CpyError=%CpyError% lib\dll\libzstd.*)
15-
COPY lib\dll\example\Makefile bin\example\ || (SET CpyError=%CpyError% lib\dll\example\Makefile)
16-
COPY lib\dll\example\fullbench-dll.* bin\example\ || (SET CpyError=%CpyError% lib\dll\example\fullbench)
17-
COPY lib\dll\example\README.md bin\ || (SET CpyError=%CpyError% lib\dll\example\README.md)
18-
COPY lib\zstd.h bin\include\ || (SET CpyError=%CpyError% lib\zstd.h)
19-
COPY lib\zstd_errors.h bin\include\ || (SET CpyError=%CpyError% lib\zstd_errors.h)
20-
COPY lib\dictBuilder\zdict.h bin\include\ || (SET CpyError=%CpyError% lib\dictBuilder\zdict.h)
21-
COPY programs\zstd.exe bin\zstd.exe || (SET CpyError=%CpyError% programs\zstd.exe)
1+
@echo off
2+
setlocal
223

23-
IF "[%CpyError%]" == "[]" goto :EOF
4+
rem Create required directories.
5+
mkdir bin\dll bin\static bin\example bin\include
246

25-
:error
26-
echo Failed with error #%errorlevel%: unable to copy following files:
27-
echo %CpyError%
28-
exit /b %errorlevel%
7+
rem Copy files using a subroutine. Exits immediately on failure.
8+
call :copyFile "tests\fullbench.c" "bin\example\"
9+
call :copyFile "programs\datagen.c" "bin\example\"
10+
call :copyFile "programs\datagen.h" "bin\example\"
11+
call :copyFile "programs\util.h" "bin\example\"
12+
call :copyFile "programs\platform.h" "bin\example\"
13+
call :copyFile "lib\common\mem.h" "bin\example\"
14+
call :copyFile "lib\common\zstd_internal.h" "bin\example\"
15+
call :copyFile "lib\common\error_private.h" "bin\example\"
16+
call :copyFile "lib\common\xxhash.h" "bin\example\"
17+
call :copyFile "lib\libzstd.a" "bin\static\libzstd_static.lib"
18+
call :copyFile "lib\dll\libzstd.*" "bin\dll\"
19+
call :copyFile "lib\dll\example\Makefile" "bin\example\"
20+
call :copyFile "lib\dll\example\fullbench-dll.*" "bin\example\"
21+
call :copyFile "lib\dll\example\README.md" "bin\"
22+
call :copyFile "lib\zstd.h" "bin\include\"
23+
call :copyFile "lib\zstd_errors.h" "bin\include\"
24+
call :copyFile "lib\zdict.h" "bin\include\"
25+
call :copyFile "programs\zstd.exe" "bin\zstd.exe"
2926

30-
:EOF
27+
endlocal
28+
exit /b 0
29+
30+
:copyFile
31+
copy "%~1" "%~2"
32+
if errorlevel 1 (
33+
echo Failed to copy "%~1"
34+
exit 1
35+
)
36+
exit /b

0 commit comments

Comments
 (0)