-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (93 loc) · 3.06 KB
/
release.yml
File metadata and controls
102 lines (93 loc) · 3.06 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
name: Release
on:
# Manuel OU déclenchée par un tag v*
workflow_dispatch:
inputs:
tag:
description: "Tag à publier (ex: v0.2.0-rc.1)"
required: true
default: "v0.2.0-rc.1"
draft:
description: "Créer en draft"
required: true
type: boolean
default: true
push:
tags:
- "v*"
jobs:
release:
name: create/update GitHub Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt,clippy
- name: Cache
uses: Swatinem/rust-cache@v2
- name: Determine tag
id: tag
shell: bash
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${GITHUB_REF_NAME}"
fi
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "TAG=$TAG" >> "$GITHUB_ENV"
- name: Build and package (linux-x86_64)
shell: bash
run: |
set -euo pipefail
echo "Building devit for tag: ${TAG}"
# Build binaire CLI (le paquet s'appelle devit-cli, binaire devit)
cargo build -p devit-cli --bin devit --release
# Prépare le paquet
mkdir -p dist/pkg
cp target/release/devit dist/pkg/
# Fichiers optionnels si présents
[[ -f LICENSE ]] && cp LICENSE dist/pkg/ || true
[[ -f README.md ]] && cp README.md dist/pkg/ || true
# Archive + checksum
tar -czf "dist/devit-${TAG}-linux-x86_64.tar.gz" -C dist pkg
(cd dist && sha256sum "devit-${TAG}-linux-x86_64.tar.gz" > "devit-${TAG}-linux-x86_64.sha256")
# Affiche un aperçu
ls -lah dist
echo "SHA256:"
cat "dist/devit-${TAG}-linux-x86_64.sha256"
- name: Extract release notes
id: notes
shell: bash
run: |
set -euo pipefail
chmod +x scripts/extract_release_notes.sh
scripts/extract_release_notes.sh "${{ steps.tag.outputs.tag }}" > notes.md
echo "notes_file=$(pwd)/notes.md" >> "$GITHUB_OUTPUT"
echo "Notes generated for tag ${{ steps.tag.outputs.tag }}"
sed -n '1,40p' notes.md || true
- name: Decide draft flag
id: draft
shell: bash
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "draft=${{ github.event.inputs.draft }}" >> "$GITHUB_OUTPUT"
else
echo "draft=false" >> "$GITHUB_OUTPUT"
fi
- name: Create or update release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
files: |
dist/*
draft: ${{ steps.draft.outputs.draft }}
body_path: ${{ steps.notes.outputs.notes_file }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}