forked from emacs-ng/emacs-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (126 loc) · 4.96 KB
/
release.yml
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
name: Create Release Asset
on:
schedule:
- cron: "0 0 * * 0" # weekly
workflow_dispatch:
push:
tags:
'v*'
jobs:
prepare_env:
name: Prepare build version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get latest release
continue-on-error: true
id: cur_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: draft
- name: Set outputs
id: vars
run: |
tag=${GITHUB_REF#refs/tags/*}
sha=$(git rev-parse --short HEAD)
version=$([[ $tag == v* ]] && echo ${tag:1} || echo 0.0.$sha)
cur_ver=$([[ ${{ steps.cur_release.outcome }} == failure ]] && echo v0 || echo ${{ steps.cur_release.outputs.release }})
[[ v$version == $cur_ver ]] && exit 1
prerelease=$([[ $tag == v* ]] && echo false || echo true)
rust_cache=${{ hashFiles('**/rust-toolchain', '**/Cargo.lock') }}
echo "version=$version" >> $GITHUB_ENV
echo "arch=$(dpkg-architecture -q DEB_BUILD_ARCH)" >> $GITHUB_ENV
echo "prerelease=$prerelease" >> $GITHUB_ENV
echo "rust_cache=$rust_cache" >> $GITHUB_ENV
echo "rust_toolchain=$(cat rust-toolchain)" >> $GITHUB_ENV
outputs:
version: ${{ env.version }}
arch: ${{ env.arch }}
prerelease: ${{ env.prerelease }}
rust_cache: ${{ env.rust_cache }}
rust_toolchain: ${{ env.rust_toolchain }}
build:
needs: prepare_env
name: Build and release
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
build: [general, webrender]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v2
- name: rust setup
id: rust-setup
run: |
rustup install $(cat rust-toolchain)
rustup component add rustfmt-preview
- name: Cache rust
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
./target
key: ${{ runner.os }}-${{ matrix.build }}-cargo-${{ needs.prepare_env.outputs.rust_cache }}
restore-keys: |
${{ runner.os }}-${{ matrix.build }}-cargo
- name: Build project
if: ${{ matrix.build == 'general' }}
run: |
version=${{ needs.prepare_env.outputs.version }}
bin_version=$version
echo "version=$version" >> $GITHUB_ENV
echo "bin_version=$bin_version" >> $GITHUB_ENV
./build_emacs_ng.sh $bin_version
- name: Build project with webrender
if: ${{ matrix.build == 'webrender' }}
run: |
version=${{ needs.prepare_env.outputs.version }}
bin_version=$version.webrender
echo "version=$version" >> $GITHUB_ENV
echo "bin_version=$bin_version" >> $GITHUB_ENV
./build_emacs_ng.sh $bin_version --with-webrender --with-winit
- name: Reduce cache
continue-on-error: true
run: |
## Reduce Cache
# https://bheisler.github.io/post/efficient-use-of-travis-ci-cache-for-rust/
# Delete loose files in the release/debug directory
sudo find ./target/release -maxdepth 1 -type f -delete
# Delete just meta data
sudo rm -f ./target/.rustc_info.json
# Also delete cargo's registry index. This is updated on every build, but it's
# way cheaper to re-download than the whole cache is.
sudo rm -rf ~/.cargo/registry/index/
- name: Get release
id: get_release_by_tag
uses: jonfriesen/[email protected]
with:
tag_name: v${{ env.version }}
continue-on-error: true
- name: Do Release
if: steps.get_release_by_tag.outcome == 'failure'
id: do_release
uses: ncipollo/release-action@v1
with:
tag: v${{ env.version }}
name: emacs-ng_${{ env.version }}
draft: false
prerelease: ${{ needs.prepare_env.outputs.prerelease }}
artifactErrorsFailBuild: true
artifacts: ./emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb
artifactContentType: application/vnd.debian.binary-package
token: ${{ secrets.GITHUB_TOKEN }}
- name: Do upload to release
if: steps.get_release_by_tag.outcome == 'success'
id: upload_release_asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.get_release_by_tag.outputs.upload_url }}
asset_path: ./emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb
asset_name: emacs-ng_${{ env.bin_version }}_${{ needs.prepare_env.outputs.arch }}.deb
asset_content_type: application/vnd.debian.binary-package