-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/cli #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/cli #13
Changes from all commits
613dd63
676ea25
a61c7c9
af2a6cb
3e99f29
6b4a85a
bbf493e
552e720
9e99471
11441eb
cfcc647
7162c3b
4cbdec6
3e5e0b6
7f0cd4d
3371861
b193b5d
152f1a5
a0d46fc
4e8610d
23cf113
5f05047
b63e1fb
ad033a2
64813e0
f77bbf0
8609ad1
3ed83d3
9d3216c
73034c0
1711c39
87dc5de
d48c1d9
ec6fb64
97f7924
497c54a
a85a421
c9b2266
dda07c0
1fa222f
e3539e4
9a17f8d
a48f4a8
1bdd56f
ccda21b
a43e0a6
3231372
c4e2edd
c6c9490
fa85310
e7c5730
4df1aab
102e7a6
8642174
50fbd32
29a7d33
5706858
b1a6c48
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,141 @@ | |||||||||||||||||||||||||||||
| name: Create Github release | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| on: | |||||||||||||||||||||||||||||
| push: | |||||||||||||||||||||||||||||
| tags: | |||||||||||||||||||||||||||||
| - "v*.*.*" # triggers on tags like vX.Y.Z | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| run-only-on-main-branch: | |||||||||||||||||||||||||||||
| name: Verify main branch | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - name: Checkout repository | |||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Check if tag is on main | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| git fetch origin main | |||||||||||||||||||||||||||||
| if git merge-base --is-ancestor $GITHUB_SHA origin/main; then | |||||||||||||||||||||||||||||
| echo "Tag is on main" | |||||||||||||||||||||||||||||
| else | |||||||||||||||||||||||||||||
| echo "Tag is NOT on main, skipping" | |||||||||||||||||||||||||||||
| #exit 1 | |||||||||||||||||||||||||||||
| fi | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| build-native: | |||||||||||||||||||||||||||||
| name: Build on ${{ matrix.os }} | |||||||||||||||||||||||||||||
| runs-on: ${{ matrix.os }} | |||||||||||||||||||||||||||||
| needs: run-only-on-main-branch | |||||||||||||||||||||||||||||
| strategy: | |||||||||||||||||||||||||||||
| matrix: | |||||||||||||||||||||||||||||
| os: [windows-latest, ubuntu-latest, macos-latest] | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - name: Checkout repository | |||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Set up GraalVM | |||||||||||||||||||||||||||||
| uses: graalvm/setup-graalvm@eec48106e0bf45f2976c2ff0c3e22395cced8243 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| java-version: "21" | |||||||||||||||||||||||||||||
| distribution: "graalvm" | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Build native image | |||||||||||||||||||||||||||||
| run: mvn -B clean package -Pnative | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Locate built executable | |||||||||||||||||||||||||||||
| id: find_exe | |||||||||||||||||||||||||||||
| shell: bash | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| mkdir dist | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| OS_NAME=${{ matrix.os }} | |||||||||||||||||||||||||||||
| if [[ "$OS_NAME" == "windows-latest" ]]; then | |||||||||||||||||||||||||||||
| BIN_PATH=$(find jfiletreeprettyprinter-cli/target -type f -name "jfiletreeprettyprinter.exe") | |||||||||||||||||||||||||||||
| else | |||||||||||||||||||||||||||||
| BIN_PATH=$(find jfiletreeprettyprinter-cli/target -type f -name "jfiletreeprettyprinter") | |||||||||||||||||||||||||||||
| fi | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| echo "Found binary: $BIN_PATH" | |||||||||||||||||||||||||||||
| cp "$BIN_PATH" dist/ | |||||||||||||||||||||||||||||
| echo "bin_path=$BIN_PATH" >> $GITHUB_OUTPUT | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Zip executable | |||||||||||||||||||||||||||||
| id: zip_exe | |||||||||||||||||||||||||||||
| shell: bash | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| VERSION=${GITHUB_REF_NAME} | |||||||||||||||||||||||||||||
| OS_NAME=${{ matrix.os }} | |||||||||||||||||||||||||||||
| case "$OS_NAME" in | |||||||||||||||||||||||||||||
| ubuntu-latest) SAFE_OS_NAME="linux" ;; | |||||||||||||||||||||||||||||
| windows-latest) SAFE_OS_NAME="windows" ;; | |||||||||||||||||||||||||||||
| macos-latest) SAFE_OS_NAME="macos" ;; | |||||||||||||||||||||||||||||
| *) SAFE_OS_NAME="$OS_NAME" ;; | |||||||||||||||||||||||||||||
| esac | |||||||||||||||||||||||||||||
| ZIP_NAME="jfiletreeprettyprinter-${VERSION}-${SAFE_OS_NAME}.zip" | |||||||||||||||||||||||||||||
| echo "Zip to create: $ZIP_NAME" | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| cd dist | |||||||||||||||||||||||||||||
| if [[ "$SAFE_OS_NAME" == "windows" ]]; then | |||||||||||||||||||||||||||||
| powershell Compress-Archive -Path * -DestinationPath "$ZIP_NAME" | |||||||||||||||||||||||||||||
| else | |||||||||||||||||||||||||||||
| tar -a -c -f "$ZIP_NAME" * | |||||||||||||||||||||||||||||
| fi | |||||||||||||||||||||||||||||
| echo "zip_path=dist/$ZIP_NAME" >> $GITHUB_OUTPUT | |||||||||||||||||||||||||||||
| cd .. | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Upload artifact | |||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| name: release-zips-${{ matrix.os }} | |||||||||||||||||||||||||||||
| path: ${{ steps.zip_exe.outputs.zip_path }} | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| release: | |||||||||||||||||||||||||||||
|
Comment on lines
29
to
96
Check warningCode scanning / CodeQL Workflow does not contain permissions Medium
Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Copilot AutofixAI 4 months ago The best and most secure way to resolve this problem is to add a permissions:
contents: readunder the
Suggested changeset
1
.github/workflows/create-github-release.yaml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||
| name: Create GitHub Release | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| needs: build-native | |||||||||||||||||||||||||||||
| permissions: | |||||||||||||||||||||||||||||
| contents: write | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - name: Checkout repository | |||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Download build artifacts | |||||||||||||||||||||||||||||
| uses: actions/download-artifact@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| path: release_zips | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Extract changelog for current version | |||||||||||||||||||||||||||||
| id: changelog | |||||||||||||||||||||||||||||
| shell: bash | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| TAG="${GITHUB_REF_NAME#v}" # Remove leading "v" (e.g. vX.Y.Z → X.Y.Z) | |||||||||||||||||||||||||||||
| echo "Extracting changelog for version $TAG" | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| # Extract section for this version up to the next version header | |||||||||||||||||||||||||||||
| awk "/## \\[$TAG\\]/,/^---/" CHANGELOG.md > release_notes.tmp | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| # Clean up formatting (remove trailing ---) | |||||||||||||||||||||||||||||
| sed -i '/^---/d' release_notes.tmp | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| # Verify | |||||||||||||||||||||||||||||
| echo "==== Extracted release notes ====" | |||||||||||||||||||||||||||||
| cat release_notes.tmp | |||||||||||||||||||||||||||||
| echo "================================" | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| echo "body_path=release_notes.tmp" >> $GITHUB_OUTPUT | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Create GitHub Release | |||||||||||||||||||||||||||||
| uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| name: "JFileTreePrettyPrinter ${{ github.ref_name }}" | |||||||||||||||||||||||||||||
| body_path: ${{ steps.changelog.outputs.body_path }} | |||||||||||||||||||||||||||||
| files: release_zips/**/*.zip | |||||||||||||||||||||||||||||
| draft: true | |||||||||||||||||||||||||||||
| prerelease: false | |||||||||||||||||||||||||||||
| env: | |||||||||||||||||||||||||||||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |||||||||||||||||||||||||||||
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 4 months ago
The fix is to explicitly add a
permissionsblock for therun-only-on-main-branchjob, constraining it to the minimum required privilege. Since this job only checks the ancestry of a tag (via git), it does not require write access—just read access to the repository contents. Therefore, you should addpermissions: contents: readto therun-only-on-main-branchjob (underjobs: run-only-on-main-branch:and abovesteps:). No other changes are required. Repeat this pattern for any other similar jobs lacking permission specification, but in this snippet, only the flagged job needs to be changed.