-
Notifications
You must be signed in to change notification settings - Fork 21
142 lines (128 loc) · 6.11 KB
/
Copy pathrelease.yml
File metadata and controls
142 lines (128 loc) · 6.11 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
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:
permissions:
contents: write
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Get the release version from the tag
if: env.VERSION == ''
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Show the version
run: |
echo "version is: $VERSION"
- name: Check that tag version and Cargo.toml version are the same
shell: bash
run: |
if ! grep -q "version = \"${VERSION#v}\"" Cargo.toml; then
echo "version does not match Cargo.toml" >&2
exit 1
fi
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create "$VERSION" --draft --verify-tag --title "$VERSION"
outputs:
version: ${{ env.VERSION }}
build-release:
name: Build ${{ matrix.target }}${{ matrix.suffix }}
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# Linux (via cross)
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
- { target: x86_64-unknown-linux-musl, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
- { target: aarch64-unknown-linux-musl, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
# Additional Linux architectures
- { target: armv7-unknown-linux-gnueabihf, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
- { target: i686-unknown-linux-gnu, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
- { target: riscv64gc-unknown-linux-gnu, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
- { target: powerpc64le-unknown-linux-gnu, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
# Linux pre_bash_4_4
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "--features pre_bash_4_4", suffix: "_pre_bash_4_4" }
# FreeBSD (via cross)
- { target: x86_64-unknown-freebsd, os: ubuntu-latest, build_tool: cross, lib: libflyline.so, feature_flags: "", suffix: "" }
# macOS (native cargo)
- { target: x86_64-apple-darwin, os: macos-latest, build_tool: cargo, lib: libflyline.dylib, feature_flags: "", suffix: "" }
- { target: aarch64-apple-darwin, os: macos-latest, build_tool: cargo, lib: libflyline.dylib, feature_flags: "", suffix: "" }
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.build_tool == 'cross'
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Build ${{ matrix.target }}${{ matrix.suffix }}
run: ${{ matrix.build_tool }} build --release --target ${{ matrix.target }} ${{ matrix.feature_flags }}
- name: Prepare release artifact
run: |
ARCHIVE="libflyline-${{ github.ref_name }}-${{ matrix.target }}${{ matrix.suffix }}"
echo "ARCHIVE=$ARCHIVE" >> $GITHUB_ENV
- name: Build archive
shell: bash
run: |
version="${{ needs.create-release.outputs.version }}"
version_no_v="${version#v}"
lib_versioned="${{ matrix.lib }}.$version_no_v"
cp "target/${{ matrix.target }}/release/${{ matrix.lib }}" "target/${{ matrix.target }}/release/$lib_versioned"
tar czf "$ARCHIVE.tar.gz" -C "target/${{ matrix.target }}/release" "$lib_versioned"
shasum -a 256 "$ARCHIVE.tar.gz" > "$ARCHIVE.tar.gz.sha256"
echo "ASSET=$ARCHIVE.tar.gz" >> $GITHUB_ENV
echo "ASSET_SUM=$ARCHIVE.tar.gz.sha256" >> $GITHUB_ENV
- name: Upload release archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
version="${{ needs.create-release.outputs.version }}"
gh release upload "$version" ${{ env.ASSET }} ${{ env.ASSET_SUM }}
publish-release:
name: publish-release
needs: [create-release, build-release]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Upload install.sh to release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload "${{ needs.create-release.outputs.version }}" install.sh --clobber
- name: Mark release as prerelease
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release edit "${{ needs.create-release.outputs.version }}" --prerelease --draft=false --repo HalFrgrd/flyline
test-installation:
name: test-installation (${{ matrix.target }})
needs: [create-release, publish-release]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: [install-test-alpine, install-test-ubuntu, install-test-arch, install-test-bash-3-2-57]
steps:
- uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Test installation
env:
FLYLINE_INSTALL_VERSION: ${{ needs.create-release.outputs.version }}
run: |
docker buildx bake -f docker-bake.hcl ${{ matrix.target }}