-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (116 loc) · 4.52 KB
/
Copy pathrelease.yaml
File metadata and controls
137 lines (116 loc) · 4.52 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
name: Build precompiled NIFs
on:
push:
tags:
- "v*"
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.16", "2.15"]
job:
- {
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: aarch64-apple-darwin, os: macos-13 }
- { target: x86_64-apple-darwin, os: macos-13 }
- { 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 source code
uses: actions/checkout@v4
- name: Extract project version
shell: bash
run: |
# Get the project version from mix.exs
echo "PROJECT_VERSION=$(sed -n 's/^ @version "\(.*\)"/\1/p' mix.exs | head -n1)" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: ${{ matrix.job.target }}
- name: Build the project
id: build-crate
uses: philss/rustler-precompiled-action@v1.0.1
with:
project-name: rrule_codec_rs
project-version: ${{ env.PROJECT_VERSION }}
target: ${{ matrix.job.target }}
nif-version: ${{ matrix.nif }}
use-cross: ${{ matrix.job.use-cross }}
project-dir: "native/rrule_codec_rs"
- name: Artifact upload
uses: actions/upload-artifact@v4
with:
name: ${{ steps.build-crate.outputs.file-name }}
path: ${{ steps.build-crate.outputs.file-path }}
publish_release:
name: Create GitHub Release and Update Checksums
needs: build_release
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # Need full history for force push
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List downloaded artifacts
run: find artifacts -type f | sort
- name: Generate checksums and update checksum file
run: |
# Generate checksums for all NIF binaries
cd artifacts
# Create temporary checksum data
echo "# Generated checksums for ${{ github.ref_name }}" > ../temp_checksums.txt
# Generate checksums for each file
find . -type f -name "*.tar.gz" | while read file; do
checksum=$(sha256sum "$file" | cut -d' ' -f1)
filename=$(basename "$file")
echo "\"$filename\" => \"sha256:$checksum\"," >> ../temp_checksums.txt
done
cd ..
# Update the checksum file (you'll need to adapt this format)
# This assumes the checksum file has a specific Elixir format
cat > checksum-Elixir.RruleCodec.Rrule.Api.exs << 'EOF'
# Checksums for precompiled NIFs - ${{ github.ref_name }}
%{
EOF
# Add the checksums (remove the last comma)
sed '$s/,$//' temp_checksums.txt | grep -v "^#" >> checksum-Elixir.RruleCodec.Rrule.Api.exs
echo "}" >> checksum-Elixir.RruleCodec.Rrule.Api.exs
- name: Commit checksums and force push tag
run: |
# Configure git
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Commit the updated checksum file
git add checksum-Elixir.RruleCodec.Rrule.Api.exs
git commit -m "chore: update checksums for ${{ github.ref_name }}"
git push origin HEAD:main
# Force push the tag to point to the new commit with checksums
git tag -f ${{ github.ref_name }}
git push origin ${{ github.ref_name }} --force
- name: Publish GitHub Release
uses: softprops/action-gh-release@v1
with:
files: artifacts/**/*
generate_release_notes: true
prerelease: ${{ contains(github.ref_name, '-') }}