Skip to content

Commit 62dd3e8

Browse files
committed
add workflow files also
1 parent aec3027 commit 62dd3e8

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# This specific workflow reads the version from the Cargo.toml file, so it is fairly rust specific right now.
2+
# It checks for a tag matching v* and if it does not exist, it creates the tag and calls the create-release workflow.
3+
# Steps:
4+
# - Get the version from the Cargo.toml file
5+
# - Check if the tag already exists
6+
# - If not:
7+
# - Create the tag
8+
# - Call the create-release workflow
9+
# Errors:
10+
# - If no version is found in the Cargo.toml file, the workflow will fail
11+
# - If the create-release workflow fails, the workflow will fail
12+
# Maintenance:
13+
# - Update the Rust version in the create-release workflow to match the Rust version you compile with
14+
15+
name: Check for new version
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
22+
jobs:
23+
check-new-tag:
24+
runs-on: ubuntu-latest
25+
permissions:
26+
contents: write
27+
actions: read
28+
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
33+
- name: Get version from Cargo.toml
34+
id: get_version
35+
run: |
36+
# Try to get version from Cargo.toml first
37+
if [ -f "Cargo.toml" ]; then
38+
VERSION=$(grep '^version =' Cargo.toml | cut -d'"' -f2)
39+
else
40+
echo "No Cargo.toml found to determine version"
41+
exit 1
42+
fi
43+
44+
# make sure we have a version
45+
if [ -z "$VERSION" ]; then
46+
echo "No version found in Cargo.toml"
47+
exit 1
48+
fi
49+
50+
# We have a version, the tag has a 'v' prefix
51+
echo "version=$VERSION" >> $GITHUB_OUTPUT
52+
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
53+
echo "Detected version: $VERSION"
54+
55+
- name: Check if the release already exists
56+
uses: insightsengineering/release-existence-action@v1
57+
id: check_release
58+
with:
59+
release-tag: '${{ steps.get_version.outputs.tag }}'
60+
61+
outputs:
62+
release_exists: ${{ steps.check_release.outputs.release-exists }}
63+
version: ${{ steps.get_version.outputs.version }}
64+
tag: ${{ steps.get_version.outputs.tag }}
65+
66+
run-tests:
67+
name: run_static_tests
68+
uses: holtjma/shared_github_workflows/.github/workflows/rust-static-test.yml@v0.4.0
69+
# uses: ./.github/workflows/rust-static-test.yml
70+
needs: check-new-tag
71+
if: needs.check-new-tag.outputs.release_exists == 'false'
72+
with:
73+
rust_version: 1.88.0 # if you change these, you need to update the create-release version also (below)
74+
test_docs: true
75+
76+
# Build the binary and tarball wrapping the binary
77+
call-create-release:
78+
name: Call create-release workflow
79+
needs: [check-new-tag, run-tests] # only run if the tests passed
80+
if: needs.check-new-tag.outputs.release_exists == 'false'
81+
uses: holtjma/shared_github_workflows/.github/workflows/create-release.yml@v0.4.0
82+
#uses: ./.github/workflows/create-release.yml
83+
permissions:
84+
contents: write
85+
with:
86+
release_name: 'pb-StarPhase'
87+
binary_name: pbstarphase
88+
tag: ${{ needs.check-new-tag.outputs.tag }}
89+
rust_version: 1.88.0 # ideally, this would be an env variable, but actions does not seem to support that

.github/workflows/test-ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Static CI
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
call-external:
7+
uses: holtjma/shared_github_workflows/.github/workflows/rust-static-test.yml@v0.4.0
8+
with:
9+
rust_version: 1.88.0
10+
test_docs: true

0 commit comments

Comments
 (0)