-
-
Notifications
You must be signed in to change notification settings - Fork 4
115 lines (101 loc) · 3.72 KB
/
release.yml
File metadata and controls
115 lines (101 loc) · 3.72 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
name: Build Precompiled NIFs
on:
push:
tags:
- "*.*.*"
workflow_dispatch:
inputs:
test_only:
description: "Test run (skip publishing release)"
required: false
default: "false"
type: choice
options:
- "false"
- "true"
permissions:
contents: write
jobs:
build_release:
name: NIF ${{ matrix.nif }} - ${{ matrix.job.target }} (${{ matrix.job.os }})
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
nif: ["2.15"]
job:
- { target: aarch64-apple-darwin, os: macos-15 }
- { target: x86_64-apple-darwin, os: macos-15 }
- {
target: aarch64-unknown-linux-gnu,
os: ubuntu-24.04,
use-cross: true,
}
- {
target: aarch64-unknown-linux-musl,
os: ubuntu-24.04,
use-cross: true,
}
- { target: x86_64-unknown-linux-gnu, os: ubuntu-24.04 }
- {
target: x86_64-unknown-linux-musl,
os: ubuntu-24.04,
use-cross: true,
}
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Extract and validate project version
shell: bash
run: |
# Extract version from mix.exs @version attribute
VERSION=$(sed -n 's/^[[:space:]]*@version "\(.*\)"/\1/p' mix.exs | head -n1)
if [ -z "$VERSION" ]; then
echo "::error::Failed to extract version from mix.exs"
exit 1
fi
# Check if this is a tag push or workflow_dispatch
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
# Extract git tag from GITHUB_REF_NAME (e.g., "0.9.0" or "v0.9.0")
GIT_TAG="${GITHUB_REF_NAME}"
# Validate that git tag matches mix.exs version
# Strip optional 'v' prefix for comparison
TAG_VERSION="${GIT_TAG#v}"
if [ "$VERSION" != "$TAG_VERSION" ]; then
echo "::error::Version mismatch: mix.exs version is '$VERSION' but git tag is '$GIT_TAG'"
exit 1
fi
echo "✓ Version validation passed: mix.exs version '$VERSION' matches tag '$GIT_TAG'"
else
# workflow_dispatch or other non-tag trigger
echo "ℹ Using version from mix.exs: '$VERSION' (not a tag push)"
fi
echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV
- name: Install Rust toolchain
run: |
rustup update stable
rustup default stable
rustup target add ${{ matrix.job.target }}
- name: Build the project
id: build-crate
uses: philss/rustler-precompiled-action@853ac56183f29a080304df3ff8a194b5bbdc24cc # v1.1.4
with:
project-name: ecto_libsql
project-version: ${{ env.PROJECT_VERSION }}
target: ${{ matrix.job.target }}
nif-version: ${{ matrix.nif }}
use-cross: ${{ matrix.job.use-cross && 'true' || '' }}
project-dir: "."
- name: Artifact upload
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
with:
name: ${{ steps.build-crate.outputs.file-name }}
path: ${{ steps.build-crate.outputs.file-path }}
- name: Publish archives and packages
if: startsWith(github.ref, 'refs/tags/') && inputs.test_only != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_FILE_PATH: ${{ steps.build-crate.outputs.file-path }}
run: gh release upload "${GITHUB_REF_NAME}" "${RELEASE_FILE_PATH}" --clobber