forked from langston-barrett/tree-crasher
-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (120 loc) · 4.41 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
130
131
name: release
on:
push:
branches:
- release*
tags:
- 'v*'
env:
# The NAME makes it easier to copy/paste snippets from other CI configs
NAME: tree-crasher
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: release
uses: ncipollo/release-action@v1
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
artifactErrorsFailBuild: true
body: "See [CHANGELOG.md](https://github.com/langston-barrett/${{ env.NAME }}/blob/main/CHANGELOG.md)."
draft: true
token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to crates.io
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
# Only push on actual release tags
PUSH: ${{ startsWith(github.ref, 'refs/tags/v') }}
run: |
# tree-crasher-{regex,solidity,sql} currently aren't suitable for upload to
# crates.io because they have git dependencies
for pkg in tree-crasher{,-c,-css,-html,-javascript,-python,-rust,-typescript}; do
if [[ ${PUSH} == true ]]; then
cargo publish --token ${CRATES_IO_TOKEN} -p "${pkg}"
else
cargo publish --dry-run --token ${CRATES_IO_TOKEN} -p "${pkg}"
break
fi
# crates.io uses "leaky bucket" rate limiting, with a new token every
# 60s. It takes a bit to build each package, so we use 50s.
sleep 50
done
# Inspired by rustfmt:
# https://github.com/rust-lang/rustfmt/blob/master/.github/workflows/upload-assets.yml
artifacts:
needs: release
strategy:
matrix:
build: [linux-x86_64-gnu, linux-x86_64-musl, macos-x86_64]
# build: [linux-x86_64-gnu, linux-x86_64-musl, macos-x86_64, windows-x86_64-gnu, windows-x86_64-msvc]
include:
- build: linux-x86_64-gnu
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux-x86_64-musl
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
# TODO(lb): Can these also be made stable?
- build: macos-x86_64
os: macos-latest
rust: nightly
target: x86_64-apple-darwin
# TODO(lb): Currently uses unix-specific APIs.
# - build: windows-x86_64-gnu
# os: windows-latest
# rust: nightly-x86_64-gnu
# target: x86_64-pc-windows-gnu
# - build: windows-x86_64-msvc
# os: windows-latest
# rust: nightly-x86_64-msvc
# target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install rustup
shell: bash
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup-init.sh
sh rustup-init.sh -y --default-toolchain none
rustup target add ${{ matrix.target }}
- name: Add mingw64 to path for x86_64-gnu
run: echo "C:\msys64\mingw64\bin" >> $GITHUB_PATH
if: matrix.rust == 'nightly-x86_64-gnu'
shell: bash
- name: Deps
if: matrix.target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get install -y musl-tools
- name: Build executables
shell: bash
run: |
for bin in ${NAME}-{c,css,javascript,regex,rust,solidity,sql,typescript}; do
cargo build \
--bin ${bin} \
--locked \
--release \
--target=${{ matrix.target }}
cp target/${{ matrix.target }}/release/${bin} ${bin}_${{ matrix.target }}
done
- name: Upload binaries
uses: ncipollo/release-action@v1
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
with:
allowUpdates: true
artifactErrorsFailBuild: true
replacesArtifacts: false
artifacts: >
${{ env.NAME }}-c_${{ matrix.target }},
${{ env.NAME }}-css_${{ matrix.target }},
${{ env.NAME }}-javascript_${{ matrix.target }},
${{ env.NAME }}-regex_${{ matrix.target }},
${{ env.NAME }}-rust_${{ matrix.target }},
${{ env.NAME }}-typescript_${{ matrix.target }},
${{ env.NAME }}-solidity_${{ matrix.target }}
${{ env.NAME }}-sql_${{ matrix.target }}
body: "See [CHANGELOG.md](https://github.com/langston-barrett/${{ env.NAME }}/blob/main/CHANGELOG.md)."
draft: true
token: ${{ secrets.GITHUB_TOKEN }}