@@ -2,8 +2,9 @@ name: Build Static Binaries
22on : [push]
33
44jobs :
5- build :
6- name : Build
5+
6+ build-linux-amd64 :
7+ name : Build Linux amd64
78 runs-on : ubuntu-latest
89 steps :
910 - uses : actions/checkout@v2
@@ -14,3 +15,101 @@ jobs:
1415 run : sudo apt-get install -y yasm auto{gen,conf,make}
1516 - name : Build
1617 run : make
18+ - uses : actions/upload-artifact@v1
19+ with :
20+ name : linux-amd64
21+ path : bin/pdftilecut
22+
23+ build-darwin-amd64 :
24+ name : Build Darwin amd64
25+ runs-on : macos-10.15
26+ steps :
27+ - uses : actions/checkout@v2
28+ - name : Dependencies
29+ run : |
30+ brew update
31+ brew install go@1.13 yasm automake autogen coreutils
32+ - name : Build
33+ run : make
34+ - uses : actions/upload-artifact@v1
35+ with :
36+ name : darwin-amd64
37+ path : bin/pdftilecut
38+
39+ release :
40+ name : Release
41+ needs : [build-linux-amd64, build-darwin-amd64]
42+ runs-on : ubuntu-latest
43+ if : startsWith(github.ref, 'refs/tags/v')
44+ steps :
45+ - uses : actions/download-artifact@v1
46+ with :
47+ name : linux-amd64
48+ - uses : actions/download-artifact@v1
49+ with :
50+ name : darwin-amd64
51+ - name : Compress artifacts
52+ run : |
53+ ( cd linux-amd64; zip ../pdftilecut-linux-amd64.zip pdftilecut )
54+ ( cd darwin-amd64; zip ../pdftilecut-darwin-amd64.zip pdftilecut )
55+
56+ - uses : actions/setup-python@v1
57+ with :
58+ python-version : ' 3.x'
59+ - uses : docker://ferrarimarco/github-changelog-generator:latest
60+ with :
61+ args : -u oxplot -p pdftilecut
62+ - name : Generate Changelog
63+ id : gen_changelog
64+ env :
65+ RELEASE_REF : ${{ github.ref }}
66+ run : |
67+ cat CHANGELOG.md
68+ body="$(< CHANGELOG.md python -c '
69+ import sys
70+ import os
71+
72+ tag = os.getenv("RELEASE_REF").replace("refs/tags/", "")
73+
74+ in_block = False
75+ for l in sys.stdin:
76+ if l.startswith("## [%s]" % tag):
77+ in_block = True
78+ elif l.startswith("## ["):
79+ in_block = False
80+ if in_block:
81+ sys.stdout.write(l)
82+ ')"
83+ # https://github.com/actions/create-release/issues/25#issuecomment-575435307
84+ body="${body//$'%'/%25}"
85+ body="${body//$'\n'/%0A}"
86+ body="${body//$'\r'/%0D}"
87+ echo ref $RELEASE_REF
88+ echo body $body
89+ echo "::set-output name=release_body::$body"
90+
91+ - id : create_release
92+ uses : actions/create-release@latest
93+ env :
94+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
95+ with :
96+ tag_name : ${{ github.ref }}
97+ release_name : ${{ github.ref }}
98+ body : ${{ steps.gen_changelog.outputs.release_body }}
99+ draft : true
100+ - uses : actions/upload-release-asset@v1
101+ env :
102+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
103+ with :
104+ upload_url : ${{ steps.create_release.outputs.upload_url }}
105+ asset_path : ./pdftilecut-linux-amd64.zip
106+ asset_name : pdftilecut-linux-amd64.zip
107+ asset_content_type : application/zip
108+ - uses : actions/upload-release-asset@v1
109+ env :
110+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
111+ with :
112+ upload_url : ${{ steps.create_release.outputs.upload_url }}
113+ asset_path : ./pdftilecut-darwin-amd64.zip
114+ asset_name : pdftilecut-darwin-amd64.zip
115+ asset_content_type : application/zip
0 commit comments