Skip to content
Merged

Dev #281

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
2 changes: 1 addition & 1 deletion .github/workflows/check-installer-project-version.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: check Installer project version
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronized]
branches:
- dev
workflow_dispatch:

jobs:
checkout:
Expand Down
182 changes: 182 additions & 0 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
name: Create Draft Release

on:
pull_request:
types: [closed]
branches:
- master
workflow_dispatch:

jobs:
create-draft-release:
runs-on: [self-hosted, Linux]
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'dev')

Comment on lines +12 to +14
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Job guard is fine, but missing explicit permissions can break artifact listing and release creation

Listing workflows and artifacts needs actions: read; creating releases needs contents: write. Without explicit permissions, GITHUB_TOKEN may be insufficient on pull_request/closed and workflow_dispatch.

 on:
   pull_request:
     types: [closed]
     branches:
       - master
   workflow_dispatch:
 
+permissions:
+  contents: write   # required for release creation
+  actions: read     # required to list workflows/runs/artifacts
+  id-token: none
+  issues: read
+  pull-requests: read
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
runs-on: [self-hosted, Linux]
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'dev')
on:
pull_request:
types: [closed]
branches:
- master
workflow_dispatch:
permissions:
contents: write # required for release creation
actions: read # required to list workflows/runs/artifacts
id-token: none
issues: read
pull-requests: read
🤖 Prompt for AI Agents
.github/workflows/create-draft-release.yml around lines 12 to 14: the workflow
lacks explicit permissions which can cause GITHUB_TOKEN to be insufficient for
listing artifacts/workflows and creating releases; add a permissions block at
the top of the workflow declaring at minimum actions: read (for listing
workflows/artifacts) and contents: write (for creating releases) so the jobs
that list artifacts and create a release have the needed scopes.

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download Mac artifacts
uses: actions/github-script@v6
id: download-mac-artifacts
Comment on lines +20 to +21
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update deprecated actions to Node20-compatible versions

actionlint flagged actions using deprecated Node runtimes. Upgrade to resolve runtime failures on GitHub-hosted and many self-hosted runners.

-        uses: actions/github-script@v6
+        uses: actions/github-script@v7
...
-        uses: actions/github-script@v6
+        uses: actions/github-script@v7
...
-        uses: softprops/action-gh-release@v1
+        uses: softprops/action-gh-release@v2

Also applies to: 65-66, 171-172

🧰 Tools
🪛 actionlint (1.7.7)

20-20: the runner of "actions/github-script@v6" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🤖 Prompt for AI Agents
In .github/workflows/create-draft-release.yml around lines 20-21 (and also
update occurrences at 65-66 and 171-172), the workflow uses
actions/github-script@v6 which depends on a deprecated Node runtime; update the
action references to a Node20-compatible version (for example the latest major
that supports Node20 or switch to actions/github-script@v7+ or an alternative
maintained action), and verify any inputs or script syntax remain compatible;
replace each occurrence and run a quick workflow lint to ensure actionlint no
longer flags deprecated Node runtimes.

with:
script: |
const { owner, repo } = context.repo;
const workflows = await github.rest.actions.listRepoWorkflows({ owner, repo });
const macWorkflow = workflows.data.workflows.find(w => w.name === 'upload build artifact mac');

if (macWorkflow) {
const runs = await github.rest.actions.listWorkflowRuns({
owner,
repo,
workflow_id: macWorkflow.id,
branch: 'dev',
per_page: 1,
status: 'success'
});

if (runs.data.workflow_runs.length > 0) {
const runId = runs.data.workflow_runs[0].id;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: runId
});

for (const artifact of artifacts.data.artifacts) {
if (artifact.name === 'EmotiBitSoftware-macos') {
const download = await github.rest.actions.downloadArtifact({
owner,
repo,
artifact_id: artifact.id,
archive_format: 'zip'
});

const fs = require('fs');
fs.writeFileSync('EmotiBitSoftware-macos.zip', Buffer.from(download.data));
core.setOutput('mac-artifact-downloaded', 'true');
break;
}
}
}
}

- name: Download Windows artifacts
uses: actions/github-script@v6
id: download-win-artifacts
with:
script: |
const { owner, repo } = context.repo;
const workflows = await github.rest.actions.listRepoWorkflows({ owner, repo });
const winWorkflow = workflows.data.workflows.find(w => w.name === 'upload build artifact Windows');

if (winWorkflow) {
const runs = await github.rest.actions.listWorkflowRuns({
owner,
repo,
workflow_id: winWorkflow.id,
branch: 'dev',
per_page: 1,
status: 'success'
});

if (runs.data.workflow_runs.length > 0) {
const runId = runs.data.workflow_runs[0].id;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: runId
});

for (const artifact of artifacts.data.artifacts) {
if (artifact.name === 'EmotiBitSoftware-Windows') {
const download = await github.rest.actions.downloadArtifact({
owner,
repo,
artifact_id: artifact.id,
archive_format: 'zip'
});

const fs = require('fs');
fs.writeFileSync('EmotiBitSoftware-Windows.zip', Buffer.from(download.data));
core.setOutput('win-artifact-downloaded', 'true');
break;
}
}
}
}

- name: Generate release notes
id: generate-release-notes
run: |
RELEASE_NOTES=$(cat <<-END_OF_NOTES
# New features and bug fixes

# Firmware Installed by FirmwareInstaller
EmotiBit firmware [`vx.x.x`](enter-url-here)

# PRs completed

# Installation
#### Windows
- Download the `EmotiBitSoftware-Windows.zip` linked below.
- Extract the zip file downloaded
- run the `.msi` installer file.
- If the **Windows Defender Smartscreen** pops up, click on `More info` and `Run anyway`
- The `EmotiBit Oscilloscope` and `EmotiBit DataParser` will be installed on your system.
- You can access the software from the `Start` menu under `EmotiBit` or from the desktop shortcut.

#### macOS
- Download `EmotiBitSoftware-macOS`
- Extract the downloaded zip file.
- The extracted folder will contain `EmotiBit Oscilloscope` and `EmotiBit DataParser`.
- Right-click and select `Open` to run the executables

#### Linux
- Download the source code linked below. Follow the steps in the [ReadMe](https://github.com/EmotiBit/ofxEmotiBit#readme).


END_OF_NOTES
)
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Get version from source
id: get_version
run: |
VERSION=$(grep src/ofxEmotiBitVersion.h -e "ofxEmotiBitVersion" | grep -o '"[^"]*"' | tr -d '"')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT

- name: Create config.txt
id: create-config
run: |
CONFIG_CONTENT=$(cat <<-END_OF_CONFIG
{
"WifiCredentials": [
{
"ssid": "YOUR_WIFI_NAME_GOES_HERE",
"password": "YOUR_WIFI_PASSWORD_GOES_HERE"
}
]
}
END_OF_CONFIG
)
echo "$CONFIG_CONTENT" > config.txt
echo "Config file created successfully"

- name: Create Draft Release
id: create-release
uses: softprops/action-gh-release@v1
with:
draft: true
tag_name: ${{ steps.get_version.outputs.tag }}
name: Draft Release ${{ steps.get_version.outputs.tag }}
body: ${{ steps.generate-release-notes.outputs.release_notes }}
files: |
EmotiBitSoftware-macos.zip
EmotiBitSoftware-Windows.zip
config.txt
env:
Comment on lines +176 to +181
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Gracefully handle missing artifacts to avoid release step failures

If either artifact isn’t found, softprops/action-gh-release will fail when files are missing. Either conditionally include files, or instruct the action to ignore unmatched files.

         with:
           draft: true
           tag_name: ${{ steps.get_version.outputs.tag }}
           name: Draft Release ${{ steps.get_version.outputs.tag }}
           body: ${{ steps.generate-release-notes.outputs.release_notes }}
+          fail_on_unmatched_files: false
           files: |
             EmotiBitSoftware-macos.zip
             EmotiBitSoftware-Windows.zip
             config.txt
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
body: ${{ steps.generate-release-notes.outputs.release_notes }}
files: |
EmotiBitSoftware-macos.zip
EmotiBitSoftware-Windows.zip
config.txt
env:
with:
draft: true
tag_name: ${{ steps.get_version.outputs.tag }}
name: Draft Release ${{ steps.get_version.outputs.tag }}
body: ${{ steps.generate-release-notes.outputs.release_notes }}
fail_on_unmatched_files: false
files: |
EmotiBitSoftware-macos.zip
EmotiBitSoftware-Windows.zip
config.txt
🤖 Prompt for AI Agents
In .github/workflows/create-draft-release.yml around lines 176-181, the release
step will fail when listed artifact files are missing; update the workflow to
either (A) detect whether each artifact exists prior to invoking
softprops/action-gh-release and only pass the paths for files that exist, or (B)
add the action input to ignore unmatched files (e.g., enable the option that
allows unmatched file patterns) so missing artifacts do not cause the step to
fail; implement one of these approaches and ensure the files list is built or
the action configured accordingly.

GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
*Results.txt
*/bin
EmotiBitIcons/otherFormats
*/*xcodeproj/*data/*
*/*xcodeproj/*workspace/*
*/*xcodeproj/*workspace/*
**/xcuser*/**
Comment on lines +54 to +55
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Over-broad Xcode ignore may drop shared schemes from future changes

Ignoring the entire project.xcworkspace subtree (Line 54) will also ignore xcshareddata, preventing shared schemes from being added/updated in the repo. You already track shared schemes in this PR; this rule will make future scheme updates silently untracked for untracked files.

Refine the patterns to ignore only per-user data:

Apply this diff:

-*/*xcodeproj/*workspace/*
-**/xcuser*/**
+**/*.xcodeproj/project.xcworkspace/xcuserdata/**
+**/*.xcodeproj/xcuserdata/**
+**/*.xcuserstate

Follow-up:

  • Verify existing shared schemes under xcshareddata remain tracked after this change. If any were accidentally ignored locally, remove from .gitignore as above, then git add them explicitly.

🏁 Script executed:

#!/bin/bash
set -e

echo "Lines 54-60 of .gitignore:"
sed -n '54,60p' .gitignore || echo "Unable to read .gitignore"

echo
echo "Occurrences of 'xcshareddata' in .gitignore:"
grep -n "xcshareddata" .gitignore || echo "None"

echo
echo "Tracked files with 'xcshareddata' in path:"
git ls-files | grep "xcshareddata" || echo "None"

Length of output: 1114


🏁 Script executed:

#!/bin/bash
set -e

echo "List of .xcworkspace directories:"
find . -type d -name "*.xcworkspace" || echo "None"

echo
echo "Contents of each .xcworkspace directory (depth 2):"
for d in $(find . -type d -name "*.xcworkspace"); do
  echo "Directory: $d"
  find "$d" -maxdepth 2 | sed 's/^/  /'
done

echo
echo "xcshareddata directories under .xcworkspace:"
find . -type d -name "xcshareddata" | grep "\.xcworkspace" || echo "None"

Length of output: 466


🏁 Script executed:

#!/bin/bash
set -e

echo "Checking .gitignore rules affecting xcshareddata files:"
files=$(git ls-files | grep '/xcshareddata/')
if [ -z "$files"; then
  echo "No xcshareddata files found"
  exit 0
fi

echo "Files to check:"
echo "$files"
echo
echo "Ignored entries (if any):"
git check-ignore -v $files || echo "None of the xcshareddata files are ignored"

Length of output: 3851


🏁 Script executed:

#!/bin/bash
set -e

echo "Inspecting contents of EmotiBitDataParser.xcodeproj at depth 2:"
find EmotiBitDataParser/EmotiBitDataParser.xcodeproj -maxdepth 2 | sed 's/^/  /'

Length of output: 480


Refine .gitignore to ignore only per-user Xcode data and preserve shared schemes

We’ve verified that none of the files under xcshareddata/ are currently ignored (all existing shared schemes remain tracked). To prevent future workspace-level shared schemes from being silently excluded, update your .gitignore to target only user data:

- */*xcodeproj/*workspace/*
- **/xcuser*/**
+ **/*.xcworkspace/xcuserdata/**
+ **/*.xcodeproj/xcuserdata/**
+ **/*.xcuserstate

Follow-up:

  • After merging, ensure no new workspace-level shared schemes (e.g. in *.xcworkspace/xcshareddata/) are omitted by your ignore rules.
  • If any shared-scheme files were previously ignored locally, remove them from .gitignore and git add those files explicitly.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
*/*xcodeproj/*workspace/*
**/xcuser*/**
**/*.xcworkspace/xcuserdata/**
**/*.xcodeproj/xcuserdata/**
**/*.xcuserstate
🤖 Prompt for AI Agents
In .gitignore around lines 54-55, the rules are too broad and may ignore
workspace-level shared schemes; narrow them to only ignore per-user Xcode data
by replacing the current patterns with ones that target xcuserdata and
xcuserstate (e.g., ignore **/xcuserdata/** and **/xcuserstate/**) while ensuring
**/xcshareddata/** remains tracked; after updating, check the repo for any
shared-scheme files that were previously ignored and, if found, remove them from
.gitignore and add them back to git so workspace-level shared schemes are
preserved.

Loading