Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita13435e

Browse files
committed
Get Solana and anchor version from toolchain
1 parent2f84364 commita13435e

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

‎extract-versions/action.yaml‎

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name:"Extract Versions"
2-
description:"Extracts Solana and Anchor versions from Cargo.lock"
2+
description:"Extracts Solana and Anchor versions fromanchor.toml orCargo.lock"
33
outputs:
44
solana_version:
55
description:"Detected Solana version"
@@ -14,33 +14,57 @@ runs:
1414
-id:extract
1515
shell:bash
1616
run:|
17-
# Extract Solana version from Cargo.lock or use override
17+
# Function to extract version from anchor.toml
18+
extract_from_anchor_toml() {
19+
local key=$1
20+
if [ -f "anchor.toml" ]; then
21+
grep "^${key}_version *= *\".*\"" anchor.toml | cut -d'"' -f2
22+
fi
23+
}
24+
25+
# Extract Solana version
1826
if [ -n "${{ github.event.inputs.solana_version }}" ]; then
1927
SOLANA_VERSION="${{ github.event.inputs.solana_version }}"
2028
echo "Using override Solana version: ${SOLANA_VERSION}"
2129
else
22-
SOLANA_VERSION=$(grep -A 2 'name = "solana-program"' Cargo.lock | grep 'version' | head -n 1 | cut -d'"' -f2)
23-
echo "Detected Solana version: ${SOLANA_VERSION}"
30+
# First try anchor.toml
31+
SOLANA_VERSION=$(extract_from_anchor_toml "solana")
32+
if [ -n "${SOLANA_VERSION}" ]; then
33+
echo "Detected Solana version from anchor.toml: ${SOLANA_VERSION}"
34+
else
35+
# Fallback to Cargo.lock
36+
SOLANA_VERSION=$(grep -A 2 'name = "solana-program"' Cargo.lock | grep 'version' | head -n 1 | cut -d'"' -f2)
37+
echo "Detected Solana version from Cargo.lock: ${SOLANA_VERSION}"
38+
fi
2439
fi
2540
echo "solana_version=${SOLANA_VERSION}" >> $GITHUB_OUTPUT
2641
echo "SOLANA_VERSION=${SOLANA_VERSION}" >> $GITHUB_ENV
2742
28-
# Extract Anchor version from Cargo.lock or use override
43+
# Extract Anchor version
2944
if [ -n "${{ github.event.inputs.anchor_version }}" ]; then
3045
ANCHOR_VERSION="${{ github.event.inputs.anchor_version }}"
3146
echo "Using override Anchor version: ${ANCHOR_VERSION}"
3247
else
33-
# Check if anchor-lang exists in Cargo.lock
34-
if grep -q 'name = "anchor-lang"' Cargo.lock; then
35-
ANCHOR_VERSION=$(grep -A 2 'name = "anchor-lang"' Cargo.lock | grep 'version' | head -n 1 | cut -d'"' -f2)
36-
echo "Detected Anchor version: ${ANCHOR_VERSION}"
37-
echo "anchor_version=${ANCHOR_VERSION}" >> $GITHUB_OUTPUT
38-
echo "ANCHOR_VERSION=${ANCHOR_VERSION}" >> $GITHUB_ENV
48+
# First try anchor.toml
49+
ANCHOR_VERSION=$(extract_from_anchor_toml "anchor")
50+
if [ -n "${ANCHOR_VERSION}" ]; then
51+
echo "Detected Anchor version from anchor.toml: ${ANCHOR_VERSION}"
3952
else
40-
echo "No Anchor version found in Cargo.lock"
53+
# Fallback to Cargo.lock
54+
if grep -q 'name = "anchor-lang"' Cargo.lock; then
55+
ANCHOR_VERSION=$(grep -A 2 'name = "anchor-lang"' Cargo.lock | grep 'version' | head -n 1 | cut -d'"' -f2)
56+
echo "Detected Anchor version from Cargo.lock: ${ANCHOR_VERSION}"
57+
else
58+
echo "No Anchor version found in anchor.toml or Cargo.lock"
59+
fi
4160
fi
4261
fi
4362
63+
if [ -n "${ANCHOR_VERSION}" ]; then
64+
echo "anchor_version=${ANCHOR_VERSION}" >> $GITHUB_OUTPUT
65+
echo "ANCHOR_VERSION=${ANCHOR_VERSION}" >> $GITHUB_ENV
66+
fi
67+
4468
# Debug environment variables
4569
echo "=== Environment Variables Debug ==="
4670
echo "Content of GITHUB_ENV file:"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp