Skip to content

Commit 06f267c

Browse files
authored
Chore: fix template/readme and update release PR scripts (#257)
* improve template and readme * release scripts * update release PR workflow
1 parent c4aa476 commit 06f267c

File tree

7 files changed

+100
-7
lines changed

7 files changed

+100
-7
lines changed

.github/workflows/create-release-pr.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ jobs:
4747
id: version
4848
uses: ./.github/actions/detect-version
4949

50+
- name: Update CHANGELOG.md
51+
run: scripts/update_changelog.sh ${{ steps.version.outputs.version }}
52+
53+
- name: Update CLI template version
54+
run: scripts/update_template_version.sh ${{ steps.version.outputs.version }}
55+
5056
- name: Configure Actions Bot
5157
uses: ./.github/actions/configure-actions-bot
5258

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ pub enum CounterInstructionSet {
7676
Increment(Increment),
7777
}
7878

79-
#[derive(Align1, Pod, Zeroable, Default, Copy, Clone, Debug, Eq, PartialEq, ProgramAccount)]
79+
#[zero_copy(pod)]
80+
#[derive(ProgramAccount, Default, Debug, Eq, PartialEq)]
8081
#[program_account(seeds = CounterSeeds)]
81-
#[repr(C, packed)]
8282
pub struct CounterAccount {
8383
pub authority: Pubkey,
8484
pub count: u64,

scripts/update_changelog.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# Update CHANGELOG.md for a new release
4+
# Takes the new version as the first argument
5+
6+
set -e # Exit on any error
7+
8+
# Check if version is provided
9+
if [ $# -eq 0 ]; then
10+
echo "Error: Version parameter is required"
11+
echo "Usage: $0 <version>"
12+
exit 1
13+
fi
14+
15+
VERSION=$1
16+
DATE=$(date +%Y-%m-%d)
17+
18+
# Path to the CHANGELOG.md file
19+
CHANGELOG_FILE="CHANGELOG.md"
20+
21+
if [ ! -f "$CHANGELOG_FILE" ]; then
22+
echo "Error: CHANGELOG.md not found at $CHANGELOG_FILE" >&2
23+
exit 1
24+
fi
25+
26+
# Get the previous version from the changelog for link generation
27+
PREVIOUS_VERSION=$(grep "^## \[" "$CHANGELOG_FILE" | head -2 | tail -1 | sed 's/.*\[\([0-9.]*\)\].*/\1/')
28+
29+
if [ -z "$PREVIOUS_VERSION" ]; then
30+
PREVIOUS_VERSION="HEAD"
31+
fi
32+
33+
# Add new version section after [Unreleased]
34+
# This replaces the [Unreleased] line with itself + blank line + new version section
35+
sed -i "s|^## \[Unreleased\]$|## [Unreleased]\\
36+
\\
37+
## [$VERSION] - $DATE|" "$CHANGELOG_FILE"
38+
39+
# Add the new version link at the bottom
40+
sed -i "/^\[unreleased\]:/a\\[$VERSION]: https://github.com/staratlasmeta/star_frame/compare/v$PREVIOUS_VERSION...v$VERSION" "$CHANGELOG_FILE"
41+
42+
# Update the [unreleased] link to compare from the new version
43+
sed -i "s|\[unreleased\]:.*|\[unreleased\]: https://github.com/staratlasmeta/star_frame/compare/v$VERSION...HEAD|" "$CHANGELOG_FILE"
44+
45+
# Verify the change
46+
if ! grep -q "## \[$VERSION\] - $DATE" "$CHANGELOG_FILE"; then
47+
echo "Error: CHANGELOG.md update verification failed" >&2
48+
exit 1
49+
fi
50+
51+
echo "CHANGELOG.md updated for version $VERSION"

scripts/update_template_version.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Script to update the star_frame version in the template cargo_toml
4+
# Takes the new version as the first argument
5+
6+
set -e # Exit on any error
7+
8+
# Check if version is provided
9+
if [ $# -eq 0 ]; then
10+
echo "Error: Version parameter is required"
11+
echo "Usage: $0 <version>"
12+
exit 1
13+
fi
14+
15+
VERSION=$1
16+
17+
# Path to the template cargo_toml file
18+
TEMPLATE_FILE="star_frame_cli/src/template/cargo_toml"
19+
20+
if [ ! -f "$TEMPLATE_FILE" ]; then
21+
echo "Error: Template file not found at $TEMPLATE_FILE" >&2
22+
exit 1
23+
fi
24+
25+
# Update the star_frame version in the template
26+
sed -i "s/star_frame = { version = \"[^\"]*\"/star_frame = { version = \"$VERSION\"/" "$TEMPLATE_FILE"
27+
28+
# Verify the change
29+
if ! grep -q "star_frame = { version = \"$VERSION\"" "$TEMPLATE_FILE"; then
30+
echo "Error: Version update verification failed" >&2
31+
exit 1
32+
fi
33+
34+
echo "Template updated to version $VERSION"

star_frame/src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn uninit_array_bytes<T: NoUninit, const N: usize>(array: &[T; N]) -> &[u8]
6565

6666
/// Quicker way to compare 32 bytes.
6767
///
68-
/// From [Typhoon](https://github.com/exotic-markets-labs/typhoon/blob/60c5197cc632f1bce07ba27876669e4ca8580421/crates/accounts/src/utils.rs#L2)
68+
/// Adapted from [Typhoon](https://github.com/exotic-markets-labs/typhoon/blob/60c5197cc632f1bce07ba27876669e4ca8580421/crates/accounts/src/utils.rs#L2)
6969
#[inline]
7070
#[must_use]
7171
pub fn fast_32_byte_eq(a: &[u8; 32], b: &[u8; 32]) -> bool {

star_frame_cli/src/template/cargo_toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ publish = false
99
release.release = false
1010

1111
[lib]
12-
crate-type = ["cdylib", "lib"]
12+
# Using only `cdylib` enables the compiler to optimize with LTO. If you need to use the library, make a separate lib crate
13+
# or add `rlib` here if the performance impact is acceptable.
14+
crate-type = ["cdylib"]
1315
name = "{name_lowercase}"
1416

1517
[features]
@@ -18,7 +20,7 @@ idl = ["star_frame/idl"]
1820

1921
[profile.release]
2022
overflow-checks = true
21-
lto = "fat"
23+
lto = "thin"
2224
codegen-units = 1
2325

2426
[dependencies]

star_frame_cli/src/template/states_rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ pub struct CounterAccountSeeds {
66
pub authority: Pubkey,
77
}
88

9-
#[derive(Align1, Pod, Zeroable, Default, Copy, Clone, Debug, Eq, PartialEq, ProgramAccount)]
9+
#[zero_copy(pod)]
10+
#[derive(Default, Debug, Eq, PartialEq, ProgramAccount)]
1011
#[program_account(seeds = CounterAccountSeeds)]
11-
#[repr(C, packed)]
1212
pub struct CounterAccount {
1313
pub authority: Pubkey,
1414
pub count: u64,

0 commit comments

Comments
 (0)