Skip to content

Commit 38b8a24

Browse files
authored
Update rust.yml
1 parent bd047c6 commit 38b8a24

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

.github/workflows/rust.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,52 @@ name: Create Release
33
on:
44
push:
55
tags:
6-
- "*" # Trigger for all tag pushes
6+
- "*" # Trigger on any tag pushes
77

88
jobs:
99
release:
1010
runs-on: ubuntu-latest
1111
steps:
12+
# Check out the repository code
1213
- name: Checkout Code
1314
uses: actions/checkout@v3
1415

16+
# Cache dependencies (example for Node.js projects)
17+
- name: Cache Node Modules
18+
uses: actions/cache@v3
19+
with:
20+
path: node_modules
21+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
22+
restore-keys: |
23+
${{ runner.os }}-node-
24+
25+
# (Optional) Install dependencies if your workflow requires them
26+
- name: Install Dependencies
27+
if: exists('package-lock.json')
28+
run: npm ci
29+
30+
# Validate and fix the tag name if it matches a 40-character hexadecimal string
1531
- id: validate_tag
1632
name: Validate and Fix Tag Name
1733
shell: bash
1834
run: |
19-
# Extract the tag name from the ref (removing 'refs/tags/')
35+
# Extract tag name from the Git reference
2036
TAG="${GITHUB_REF##*/}"
2137
echo "Original tag: ${TAG}"
22-
23-
# Check if the tag is exactly 40 hex characters (a commit SHA)
38+
39+
# If tag is exactly 40 hex characters (looks like a commit SHA), adjust it
2440
if [[ "${TAG}" =~ ^[0-9a-f]{40}$ ]]; then
25-
# If true, adjust the tag name.
26-
# Here we prefix with 'v' and use the first 7 characters (as is common for abbreviated SHAs).
2741
NEW_TAG="v${TAG:0:7}"
2842
echo "Tag appears to be a commit SHA. Adjusting tag to: ${NEW_TAG}"
2943
TAG="${NEW_TAG}"
3044
else
3145
echo "Tag is valid: ${TAG}"
3246
fi
33-
34-
# Set the adjusted tag as an output for later steps
47+
48+
# Set the adjusted tag as output for later steps
3549
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
3650
51+
# Create the GitHub release using the validated/adjusted tag
3752
- name: Create Release
3853
uses: actions/create-release@v1
3954
env:

0 commit comments

Comments
 (0)