-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (152 loc) · 5.35 KB
/
release.yml
File metadata and controls
177 lines (152 loc) · 5.35 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
177
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
build_nif:
name: NIF ${{ matrix.job.target }}
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
nif: ["2.16"]
job:
# Both Apple targets build on the native Apple Silicon runner;
# x86_64-apple-darwin is a cross-compile from arm64 using the
# stock rustup target, which is fine because no C deps of the
# NIF need native compilation at that target.
- { target: aarch64-apple-darwin, os: macos-14, lib-ext: dylib }
- { target: x86_64-apple-darwin, os: macos-14, lib-ext: dylib }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-22.04, lib-ext: so }
- { target: aarch64-unknown-linux-gnu, os: ubuntu-22.04-arm, lib-ext: so }
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
shell: bash
run: |
rustup toolchain install stable --profile minimal
rustup default stable
rustup target add ${{ matrix.job.target }}
- name: Extract project version
id: version
shell: bash
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Compute NIF feature flag
id: feature
shell: bash
run: |
echo "flag=nif_version_$(echo ${{ matrix.nif }} | tr . _)" >> "$GITHUB_OUTPUT"
- name: Build NIF
shell: bash
working-directory: native/javex_nif
run: |
cargo build --release \
--target ${{ matrix.job.target }} \
--no-default-features \
--features ${{ steps.feature.outputs.flag }}
- name: Package artifact
id: package
shell: bash
run: |
set -euo pipefail
VERSION="${{ steps.version.outputs.version }}"
NIF="${{ matrix.nif }}"
TARGET="${{ matrix.job.target }}"
SRC_EXT="${{ matrix.job.lib-ext }}"
# rustler_precompiled expects the artifact to be named with
# a `.so` suffix in the tarball regardless of the host
# platform, because Rustler renames all NIF shared libraries
# to .so inside priv/native at load time.
NAME="libjavex_nif-v${VERSION}-nif-${NIF}-${TARGET}"
ARCHIVE="${NAME}.so.tar.gz"
SRC="native/javex_nif/target/${TARGET}/release/libjavex_nif.${SRC_EXT}"
STAGE="$(mktemp -d)"
cp "${SRC}" "${STAGE}/${NAME}.so"
tar -C "${STAGE}" -czf "${ARCHIVE}" "${NAME}.so"
echo "archive=${ARCHIVE}" >> "$GITHUB_OUTPUT"
echo "name=${ARCHIVE}" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.name }}
path: ${{ steps.package.outputs.archive }}
if-no-files-found: error
publish_release:
name: Publish GitHub Release
needs: build_nif
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install git-cliff
shell: bash
run: |
set -euo pipefail
VERSION="2.6.1"
URL="https://github.com/orhun/git-cliff/releases/download/v${VERSION}/git-cliff-${VERSION}-x86_64-unknown-linux-gnu.tar.gz"
curl -sSL "$URL" -o /tmp/git-cliff.tar.gz
mkdir -p /tmp/git-cliff && tar -xzf /tmp/git-cliff.tar.gz -C /tmp/git-cliff --strip-components 1
sudo install /tmp/git-cliff/git-cliff /usr/local/bin/git-cliff
git-cliff --version
- name: Generate changelog
shell: bash
run: git-cliff --config cliff.toml --latest --strip header > CHANGES.md
- name: Download NIF artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Publish release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGES.md
files: artifacts/*
fail_on_unmatched_files: true
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
draft: false
prerelease: false
publish_hex:
name: Publish to hex.pm
needs: publish_release
runs-on: ubuntu-22.04
env:
MIX_ENV: prod
HEX_API_KEY: ${{ secrets.HEX_API_KEY }}
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
with:
experimental: true
- name: Install hex / rebar
run: |
mix local.hex --force
mix local.rebar --force
- name: Download NIF artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Generate checksum file from real artifacts
shell: bash
run: |
set -euo pipefail
OUT="checksum-Elixir.Javex.Native.exs"
{
echo "%{"
for f in artifacts/*.tar.gz; do
name="$(basename "$f")"
sum="$(sha256sum "$f" | cut -d' ' -f1)"
echo " \"${name}\" => \"sha256:${sum}\","
done
echo "}"
} > "$OUT"
echo "--- ${OUT} ---"
cat "$OUT"
- name: Fetch deps
run: mix deps.get --only prod
- name: Publish to hex
run: mix hex.publish package --yes