Skip to content

Commit

Permalink
Define QuantumPropagators.VERSION
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Dec 14, 2023
1 parent d30a08a commit 2f9f491
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,34 @@ jobs:
run: wget https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/typos.toml
- name: Spell Check
uses: crate-ci/typos@master
- name: Version Check
shell: julia --project=test {0}
run: |
using QuantumPropagators: VERSION
BRANCH = ENV["GITHUB_REF_NAME"]
if ENV["GITHUB_EVENT_NAME"] == "pull_request"
# For pull_request events, return the head (aka., "from") branch,
# not the base (aka., "to") branch.
BRANCH = ENV["GITHUB_HEAD_REF"]
end
if startswith(BRANCH, "release-")
if (length(VERSION.prerelease) == length(VERSION.build))
println("Version $VERSION on release branch OK")
else
@error "Invalid version $VERSION on release branch"
exit(1)
end
elseif (ENV["GITHUB_REF_TYPE"] == "branch") && (BRANCH != "master")
if ("dev" in VERSION.prerelease) || ("dev" in VERSION.build)
println("Version $VERSION OK with dev-suffix on $BRANCH")
else
@error "Invalid version $VERSION on branch $BRANCH: must contain dev suffix"
exit(1)
end
else
println("Version $VERSION OK on $BRANCH")
end
exit(0)
- name: Get codestyle settings
run: wget https://raw.githubusercontent.com/JuliaQuantumControl/JuliaQuantumControl/master/.JuliaFormatter.toml
- name: Install JuliaFormatter and format
Expand Down
10 changes: 10 additions & 0 deletions src/QuantumPropagators.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
module QuantumPropagators


const VERSION = let
project = joinpath(dirname(dirname(pathof(QuantumPropagators))), "Project.toml")
Base.include_dependency(project) # Retrigger precompilation when Project.toml changes
toml = read(project, String)
m = match(r"(*ANYCRLF)^version\s*=\s\"(.*)\"$"m, toml)
VersionNumber(m[1])
end


include("arnoldi.jl") # submodule Arnoldi
include("specrad.jl") # submodule SpectralRange
include("cheby.jl") # submodule Cheby
Expand Down

0 comments on commit 2f9f491

Please sign in to comment.