-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (80 loc) · 2.98 KB
/
release.yml
File metadata and controls
93 lines (80 loc) · 2.98 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
name: Release
on:
push:
tags:
- '*_v*'
jobs:
release:
runs-on: ubuntu-24.04
permissions:
contents: write
discussions: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract project and version from tag
id: extract_tag
run: |
TAG_NAME="${{ github.ref_name }}"
echo "Tag name: $TAG_NAME"
# Extract project name (everything before _v)
PROJECT_NAME=$(echo "$TAG_NAME" | sed 's/_v.*//')
echo "Project name: $PROJECT_NAME"
# Extract version (everything after _v)
VERSION=$(echo "$TAG_NAME" | sed 's/.*_v//')
echo "Version: $VERSION"
echo "project_name=$PROJECT_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Read release notes from NEWS.md
id: release_notes
run: |
NEWS_FILE="${{ steps.extract_tag.outputs.project_name }}/NEWS.md"
if [ -f "$NEWS_FILE" ]; then
echo "Found NEWS.md file: $NEWS_FILE"
RELEASE_BODY=$(cat "$NEWS_FILE")
echo "release_body<<EOF" >> $GITHUB_OUTPUT
echo "$RELEASE_BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "NEWS.md not found, using default release notes"
echo "release_body=Release ${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.14.0
with:
bazelisk-cache: true
disk-cache: ${{ github.workflow }}
repository-cache: true
- name: Build specific project
run: |
bazel build \
--verbose_failures \
//${{ steps.extract_tag.outputs.project_name }}
- name: Find and rename build artifact
id: find_artifact
run: |
# Get bazel-bin path
BAZEL_BIN_PATH=$(bazel info bazel-bin)
# Find the built zip file
OLD_ARTIFACT_PATH=$(find $BAZEL_BIN_PATH/${{ steps.extract_tag.outputs.project_name }} -name "*.zip" | head -1)
if [ -z "$OLD_ARTIFACT_PATH" ]; then
echo "Error: No zip file found for project ${{ steps.extract_tag.outputs.project_name }}"
exit 1
fi
echo "Found artifact: $OLD_ARTIFACT_PATH"
NEW_ARTIFACT_NAME="${{ github.ref_name }}.zip"
mv "$OLD_ARTIFACT_PATH" "$NEW_ARTIFACT_NAME"
echo "Renamed artifact to $NEW_ARTIFACT_NAME"
echo "artifact_path=$NEW_ARTIFACT_NAME" >> $GITHUB_OUTPUT
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: ${{ steps.release_notes.outputs.release_body }}
files: ${{ steps.find_artifact.outputs.artifact_path }}
draft: false
prerelease: false
discussion_category_name: Announcements