Skip to content

Commit

Permalink
feat: use .env file to define MAG Data Visualization toolbox version
Browse files Browse the repository at this point in the history
  • Loading branch information
mfacchinelli committed Sep 20, 2024
1 parent 92110dc commit 9ae4fa0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MAG_DATA_VISUALIZATION_VERSION=6.0.0
8 changes: 4 additions & 4 deletions .github/workflows/matlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ jobs:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: test
env:
VERSION: "6.0.0"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up MATLAB
uses: matlab-actions/[email protected]
with:
release: R2023b
- name: Load Environment Variables
uses: aarcangeli/[email protected]
- name: Package toolbox
uses: matlab-actions/[email protected]
with:
tasks: package("${{ env.VERSION }}")
tasks: package("${{ env.MAG_DATA_VISUALIZATION_VERSION }}")
- name: Upload toolbox
uses: actions/[email protected]
with:
Expand All @@ -67,6 +67,6 @@ jobs:
- name: Create release
uses: ncipollo/[email protected]
with:
tag: v${{ env.VERSION }}
tag: v${{ env.MAG_DATA_VISUALIZATION_VERSION }}
artifacts: 'artifacts/MAG Data Visualization.mltbx'
bodyFile: 'resources/release-notes.md'
1 change: 1 addition & 0 deletions resources/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
# GitHub

- Run tests also with MATLAB R2024b
- Use `.env` file to define version (also in `mag.version`)
11 changes: 5 additions & 6 deletions src/utility/+mag/version.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
if isempty(ver)

location = fileparts(mfilename("fullpath"));
fileName = fullfile(location, "../../../.github/workflows/matlab.yml");
fileName = fullfile(location, "../../../.env");

if isfile(fileName)

data = fileread(fileName);
match = regexp(data, "VERSION: ""(?<version>\d+\.\d+\.\d+)""", "once", "names");
env = loadenv(fileName);

if isempty(match)
error("Could not determine version from ""matlab.yml"" file.");
if env.isKey("MAG_DATA_VISUALIZATION_VERSION")
ver = env("MAG_DATA_VISUALIZATION_VERSION");
else
ver = match.version;
error("Could not determine version from "".env"" file.");
end
else

Expand Down

0 comments on commit 9ae4fa0

Please sign in to comment.