-
Notifications
You must be signed in to change notification settings - Fork 9
176 lines (157 loc) · 5.43 KB
/
Copy pathrelease.yml
File metadata and controls
176 lines (157 loc) · 5.43 KB
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
name: release
on:
push:
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+'
env:
CARGO_TERM_COLOR: always
EXECUTABLE_NAMES: hdri_merge lut_maker ocio_maker
jobs:
# Because github actions don't let us set dynamic
# environment variables.
env2:
name: Get misc info
runs-on: ubuntu-latest
outputs:
hash: ${{ steps.vars.outputs.HASH }}
date: ${{ steps.vars.outputs.DATE }}
date_hash_tag: ${{ steps.vars.outputs.DATE_HASH_TAG }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Get info
id: vars
shell: bash
run: |
BUILD_HASH=$(git rev-parse --short "$GITHUB_SHA")
BUILD_DATE=$(date +'%Y-%m-%d')
BUILD_DATE_HASH_TAG=$(echo $BUILD_DATE | sed -e 's/-/_/g')-${BUILD_HASH}
echo "::set-output name=HASH::$BUILD_HASH"
echo "::set-output name=DATE::$BUILD_DATE"
echo "::set-output name=DATE_HASH_TAG::$BUILD_DATE_HASH_TAG"
build:
name: Build
needs: [env2]
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [x86_64-linux, x86_64-macos, x86_64-windows]
include:
- build: x86_64-linux
os: ubuntu-20.04
rust: stable
target: x86_64-unknown-linux-gnu
cross: false
- build: x86_64-macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
cross: false
- build: x86_64-windows
os: windows-2019
rust: stable
target: x86_64-pc-windows-msvc
cross: false
steps:
- name: Install Ubuntu dependencies
if: startsWith(matrix.os, 'ubuntu')
run: sudo apt-get update && sudo apt-get install libgtk-3-dev libxcb-shape0-dev libxcb-xfixes0-dev wget
- name: Checkout sources
uses: actions/checkout@v3
- name: Install ${{ matrix.rust }} toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
- name: Build release binaries
shell: bash
run: |
if [[ "${{ matrix.os }}" =~ "ubuntu" ]]; then
# Build appimages on Ubuntu.
wget https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage
mv appimagetool-x86_64.AppImage appimagetool
chmod +x appimagetool
sudo mv appimagetool /usr/local/bin/
cargo +${{ matrix.rust }} install --git https://github.com/cessen/cargo-appimage.git --branch custom
cargo +${{ matrix.rust }} appimage --target=${{ matrix.target }}
else
cargo +${{ matrix.rust }} build --release --target=${{ matrix.target }}
fi
- name: Strip release binary (macos)
shell: bash
run: |
if [[ ! "${{ matrix.os }}" =~ ("windows"|"ubuntu") ]]; then
for executable in ${EXECUTABLE_NAMES}; do
strip "target/${{ matrix.target }}/release/${executable}"
done
fi
- name: Upload files for packaging
shell: bash
run: |
mkdir dist
for executable in ${EXECUTABLE_NAMES}; do
if [[ "${{ matrix.os }}" =~ "windows" ]]; then
cp "target/${{ matrix.target }}/release/${executable}.exe" "dist/"
elif [[ "${{ matrix.os }}" =~ "ubuntu" ]]; then
cp "${executable}"*.AppImage "dist/${executable}.AppImage"
else
cp "target/${{ matrix.target }}/release/${executable}" "dist/"
fi
done
cp LICENSE.md README.md "dist/"
- uses: actions/upload-artifact@v2.2.4
with:
name: files-${{ matrix.build }}
path: dist
publish:
name: Publish
needs: [env2, build]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- run: ls -al files-*
- name: Calculate tag name
run: |
name=dev
if [[ $GITHUB_REF == refs/tags/v* ]]; then
name=${GITHUB_REF:10}
fi
echo ::set-output name=val::$name
echo TAG=$name >> $GITHUB_ENV
id: tagname
- name: Build archive
shell: bash
run: |
set -ex
rm -rf tmp
mkdir tmp
mkdir dist
for dir in files-* ; do
platform=${dir#"files-"}
pkgname=etf_image_tools-$TAG-$platform
mkdir tmp/$pkgname
mv ${dir}/* tmp/$pkgname/
for executable in ${EXECUTABLE_NAMES}; do
if [[ $platform =~ "windows" ]]; then
chmod +x tmp/$pkgname/${executable}.exe
elif [[ $platform =~ "linux" ]]; then
chmod +x tmp/$pkgname/${executable}.AppImage
else
chmod +x tmp/$pkgname/${executable}
fi
done
if [[ $platform =~ "windows" ]]; then
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
else
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
fi
done
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
file_glob: true
tag: ${{ steps.tagname.outputs.val }}
overwrite: true
prerelease: false