Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 34 additions & 35 deletions .github/workflows/bat.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
name: Build and Test
on: [push]
permissions:
contents: read

jobs:
plugin-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: windows-latest
- os: macos-latest
steps:
- uses: actions/checkout@v6
- uses: matlab-actions/setup-matlab@v2
with:
release: latest-including-prerelease
- uses: matlab-actions/run-tests@v2
with:
source-folder: plugins

bat:
name: Build and Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Perform npm tasks
run: npm run ci

name: Build and Test
on: [push]
permissions:
contents: read

jobs:
plugin-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: windows-latest
- os: macos-latest
steps:
- uses: actions/checkout@v6
- uses: matlab-actions/setup-matlab@v3
with:
release: latest-including-prerelease
- uses: matlab-actions/run-tests@v3
with:
source-folder: plugins

bat:
name: Build and Test
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- name: Perform npm tasks
run: npm run ci
154 changes: 77 additions & 77 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
name: Publish
on:
release:
types: published
permissions:
contents: write
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.update-package-version.outputs.version }}
steps:
- uses: actions/checkout@v6
- name: Configure git
run: |
git config user.name 'Release Action'
git config user.email '<>'
- uses: actions/setup-node@v6
with:
node-version: 24
# Call `npm version`. It increments the version and commits the changes.
# We'll save the output (new version string) for use in the following
# steps
- name: Update package version
id: update-package-version
run: |
git tag -d "${{ github.event.release.tag_name }}"
VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version)
git add package.json package-lock.json
git commit -m "[skip ci] Bump $VERSION"
git push origin HEAD:main
# Now carry on, business as usual
- name: Perform npm tasks
run: npm run ci
# Finally, create a detached commit containing the built artifacts and tag
# it with the release. Note: the fact that the branch is locally updated
# will not be relayed (pushed) to origin
- name: Commit to release branch
id: release_info
run: |
# Check for semantic versioning
longVersion="${{github.event.release.tag_name}}"
echo "Preparing release for version $longVersion"
[[ $longVersion == v[0-9]*.[0-9]*.[0-9]* ]] || (echo "must follow semantic versioning" && exit 1)
majorVersion=$(echo ${longVersion%.*.*})
minorVersion=$(echo ${longVersion%.*})
# Add the built artifacts. Using --force because dist/lib should be in
# .gitignore
git add --force dist lib
# Make the commit
MESSAGE="Build for $(git rev-parse --short HEAD)"
git commit --allow-empty -m "$MESSAGE"
git tag -f -a -m "Release $longVersion" $longVersion
# Get the commit of the tag you just released
commitHash=$(git rev-list -n 1 $longVersion)
# Delete the old major and minor version tags locally
git tag -d $majorVersion || true
git tag -d $minorVersion || true
# Make new major and minor version tags locally that point to the commit you got from the "git rev-list" above
git tag -f $majorVersion $commitHash
git tag -f $minorVersion $commitHash
# Force push the new minor version tag to overwrite the old tag remotely
echo "Pushing new tags"
git push -f origin $longVersion
git push -f origin $majorVersion
git push -f origin $minorVersion
name: Publish
on:
release:
types: published
permissions:
contents: write

jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.update-package-version.outputs.version }}
steps:
- uses: actions/checkout@v6
- name: Configure git
run: |
git config user.name 'Release Action'
git config user.email '<>'
- uses: actions/setup-node@v6
with:
node-version: 24

# Call `npm version`. It increments the version and commits the changes.
# We'll save the output (new version string) for use in the following
# steps
- name: Update package version
id: update-package-version
run: |
git tag -d "${{ github.event.release.tag_name }}"
VERSION=$(npm version "${{ github.event.release.tag_name }}" --no-git-tag-version)
git add package.json package-lock.json
git commit -m "[skip ci] Bump $VERSION"
git push origin HEAD:main

# Now carry on, business as usual
- name: Perform npm tasks
run: npm run ci

# Finally, create a detached commit containing the built artifacts and tag
# it with the release. Note: the fact that the branch is locally updated
# will not be relayed (pushed) to origin
- name: Commit to release branch
id: release_info
run: |
# Check for semantic versioning
longVersion="${{github.event.release.tag_name}}"
echo "Preparing release for version $longVersion"
[[ $longVersion == v[0-9]*.[0-9]*.[0-9]* ]] || (echo "must follow semantic versioning" && exit 1)
majorVersion=$(echo ${longVersion%.*.*})
minorVersion=$(echo ${longVersion%.*})

# Add the built artifacts. Using --force because dist/lib should be in
# .gitignore
git add --force dist lib

# Make the commit
MESSAGE="Build for $(git rev-parse --short HEAD)"
git commit --allow-empty -m "$MESSAGE"
git tag -f -a -m "Release $longVersion" $longVersion

# Get the commit of the tag you just released
commitHash=$(git rev-list -n 1 $longVersion)

# Delete the old major and minor version tags locally
git tag -d $majorVersion || true
git tag -d $minorVersion || true

# Make new major and minor version tags locally that point to the commit you got from the "git rev-list" above
git tag -f $majorVersion $commitHash
git tag -f $minorVersion $commitHash

# Force push the new minor version tag to overwrite the old tag remotely
echo "Pushing new tags"
git push -f origin $longVersion
git push -f origin $majorVersion
git push -f origin $minorVersion
44 changes: 44 additions & 0 deletions devel/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## Contributing

Verify changes by running tests and building locally with the following command:

```
npm run ci
```

## Creating a New Release

Familiarize yourself with the best practices for [releasing and maintaining GitHub actions](https://docs.github.com/en/actions/creating-actions/releasing-and-maintaining-actions).

Changes should be made on a new branch. The new branch should be merged to the main branch via a pull request. Ensure that all of the CI pipeline checks and tests have passed for your changes.

After the pull request has been approved and merged to main, follow the Github process for [creating a new release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository). The release must follow semantic versioning (ex: vX.Y.Z). This will kick off a new pipeline execution, and the action will automatically be published to the GitHub Actions Marketplace if the pipeline finishes successfully. Check the [GitHub Marketplace](https://github.com/marketplace/actions/setup-matlab) and check the major version in the repository (ex: v1 for v1.0.0) to ensure that the new semantically versioned tag is available.

## Adding a Pre-Commit Hook

You can run all CI checks before each commit by adding a pre-commit hook. To do so, navigate to the repository root folder and run the following commands:

_bash (Linux/macOS)_

```sh
echo '#!/bin/sh' > .git/hooks/pre-commit
echo 'npm run ci' >> .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
```

_Command Prompt (Windows)_

```cmd
echo #!/bin/sh > .git\hooks\pre-commit
echo npm run ci >> .git\hooks\pre-commit
```

_PowerShell (Windows)_

```pwsh
Set-Content .git\hooks\pre-commit '#!/bin/sh'
Add-Content .git\hooks\pre-commit 'npm run ci'
```

> **Note:**
> Git hooks are not version-controlled, so you need to set up this hook for each fresh clone of the repository.
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
},
],
},
extensionsToTreatAsEsm: ['.ts'],
extensionsToTreatAsEsm: [".ts"],
transformIgnorePatterns: ["node_modules/(?!(@actions)/)"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"prepare": "npm run build",
"package": "ncc build --minify",
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
"all": "npm test && npm run build && npm run package",
"all": "npm run format-check && npm test && npm run build && npm run package",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only "manual" change in this PR. All the other changes come from the formatter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see I let the format-check fail in CI the first build before applying a commit with the fixes to verify the behavior.

"ci": "npm run clean && npm ci --ignore-scripts && npm run all"
},
"files": [
Expand Down
Loading
Loading