-
Notifications
You must be signed in to change notification settings - Fork 1
Workflow updates #81
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
Workflow updates #81
Changes from all commits
b302448
cf7532f
83c781c
093cd1c
d1eaa2b
39738e6
e570e17
231a707
4db4ccb
67c0a0d
1992530
672a8f1
33a1d5f
5f4a904
b582d82
7956b87
513a02d
41a6a08
1fb50aa
d97337b
4c7477d
d0ad7a7
0c14177
e13c656
efa1445
2b44c49
628120d
e211e98
9ef4a94
796a02c
1f35210
fef509a
539d3af
4f1035b
1e17432
4e5be7c
c2b54b5
ab037d8
48662cc
d7917ea
f514c47
41cdce1
630250c
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,69 @@ | ||
| # For most projects, this workflow file will not need changing; you simply need | ||
| # to commit it to your repository. | ||
| # | ||
| # You may wish to alter this file to override the set of languages analyzed, | ||
| # or to provide custom queries or build logic. | ||
| # | ||
| # ******** NOTE ******** | ||
| # We have attempted to detect the languages in your repository. Please check | ||
| # the `language` matrix defined below to confirm you have the correct set of | ||
| # supported CodeQL languages. | ||
| # | ||
| name: "CodeQL" | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ master ] | ||
| pull_request: | ||
| # The branches below must be a subset of the branches above | ||
| branches: [ master ] | ||
| schedule: | ||
| - cron: '32 11 * * 1' | ||
|
|
||
| jobs: | ||
| analyze: | ||
| name: Analyze | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| language: [ 'python' ] | ||
| # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] | ||
| # Learn more: | ||
| # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v2 | ||
|
|
||
| # Initializes the CodeQL tools for scanning. | ||
| - name: Initialize CodeQL | ||
| uses: github/codeql-action/init@v1 | ||
| with: | ||
| languages: ${{ matrix.language }} | ||
| # If you wish to specify custom queries, you can do so here or in a config file. | ||
| # By default, queries listed here will override any specified in a config file. | ||
| # Prefix the list here with "+" to use these queries and those in the config file. | ||
| # queries: ./path/to/local/query, your-org/your-repo/queries@main | ||
|
|
||
| # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). | ||
| # If this step fails, then you should remove it and run the build manually (see below) | ||
| - name: Autobuild | ||
| uses: github/codeql-action/autobuild@v1 | ||
|
|
||
| # ℹ️ Command-line programs to run using the OS shell. | ||
| # 📚 https://git.io/JvXDl | ||
|
|
||
| # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | ||
| # and modify them (or add more) to build your code if your project | ||
| # uses a compiled language | ||
|
|
||
| #- run: | | ||
| # make bootstrap | ||
| # make release | ||
|
|
||
| - name: Perform CodeQL Analysis | ||
| uses: github/codeql-action/analyze@v1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,79 +1,71 @@ | ||
| name: Publish Commander to PyPi | ||
| name: Publish CLI to PyPi | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: Version to release (Tag from Keeper-Security/keeper-sdk-pyton) | ||
| description: Version to release (Tag from Keeper-Security/keeper-sdk-python) | ||
| required: true | ||
|
|
||
| jobs: | ||
| build-n-publish: | ||
| name: Build and publish Keeper SDK for Python 📦 to PyPI | ||
| name: Build and publish Keeper CLI for Python to TestPyPI | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 25 # To keep builds from running too long | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout source code | ||
| uses: actions/checkout@v2 | ||
|
|
||
| - name: Set up Python 3.10 | ||
| - name: Set up Python 3.11 | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.10' | ||
| python-version: '3.11' | ||
| architecture: 'x64' | ||
|
|
||
| - name: Build the package | ||
| run: | | ||
| python -m pip install -U setuptools pip build wheel twine | ||
| python -m build --wheel | ||
| python -m build --wheel keepercli-package | ||
|
|
||
| - name: Archive the package | ||
| uses: actions/upload-artifact@v3 | ||
| with: | ||
| name: KeeperSdkWheel | ||
| name: KeeperCLIWheel | ||
| retention-days: 1 | ||
| path: dist/* | ||
| path: keepercli-package/dist/* | ||
| if-no-files-found: error | ||
|
|
||
| - name: Publish Commander to test PyPi | ||
| - name: Publish keepercli to test PyPi | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} | ||
| run: | | ||
| twine upload -r testpypi dist/* | ||
|
|
||
| twine upload -r testpypi keepercli-package/dist/* | ||
|
|
||
| publish-pypi: | ||
| name: Publish Keeper SDK to PyPi | ||
| name: Publish Keeper CLI to PyPi | ||
| runs-on: ubuntu-latest | ||
| needs: [build-n-publish] | ||
| environment: prod | ||
|
|
||
| steps: | ||
| - uses: actions/download-artifact@v3 | ||
| with: | ||
| name: CommanderWheel | ||
| path: dist | ||
| name: KeeperCLIWheel | ||
| path: keepercli-package/dist | ||
|
|
||
| - name: Set up Python 3.10 | ||
| - name: Set up Python 3.11 | ||
| uses: actions/setup-python@v4 | ||
| with: | ||
| python-version: '3.10' | ||
| architecture: 'x64' | ||
|
|
||
| - name: Retrieve secrets from Keeper | ||
| id: ksecrets | ||
| uses: Keeper-Security/ksm-action@master | ||
| with: | ||
| keeper-secret-config: ${{ secrets.KSM_COMMANDER_SECRET_CONFIG }} | ||
| secrets: | | ||
| gD5LOOhI5QbnSFk8mIg3gg/field/password > PYPI_PASSWORD | ||
| python-version: '3.11' | ||
|
|
||
| - name: Publish to PyPi | ||
| - name: Publish keepercli to PyPi | ||
| env: | ||
| TWINE_USERNAME: __token__ | ||
| TWINE_PASSWORD: ${{ steps.ksecrets.outputs.PYPI_PASSWORD }} | ||
| TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISH_TOKEN }} | ||
| run: | | ||
| python -m pip install -U setuptools pip wheel twine | ||
| twine upload dist/* | ||
| twine upload -r pypi keepercli-package/dist/* | ||
| Original file line number | Diff line number | Diff line change | |||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,72 +1,90 @@ | |||||||||||||||||||||||||||||
| name: Publish Keeper SDK to PyPi | |||||||||||||||||||||||||||||
| name: Publish Keeper SDK to PyPI | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| on: [workflow_dispatch] | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| jobs: | |||||||||||||||||||||||||||||
| build-wheel: | |||||||||||||||||||||||||||||
| name: Build and publish Keeper SDK for Python 📦 to PyPI | |||||||||||||||||||||||||||||
| build-and-test: | |||||||||||||||||||||||||||||
| name: Build and test Keeper SDK package | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| timeout-minutes: 25 # To keep builds from running too long | |||||||||||||||||||||||||||||
| timeout-minutes: 25 | |||||||||||||||||||||||||||||
| permissions: | |||||||||||||||||||||||||||||
| contents: read | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - name: Checkout source code | |||||||||||||||||||||||||||||
| uses: actions/checkout@v2 | |||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Set up Python 3.11 | |||||||||||||||||||||||||||||
| uses: actions/setup-python@v4 | |||||||||||||||||||||||||||||
| - name: Set up Python 3.13 | |||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| python-version: '3.11' | |||||||||||||||||||||||||||||
| python-version: '3.13' | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Install dependencies | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| pip install keepersdk-package/ | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Run unit tests | |||||||||||||||||||||||||||||
| run: python -m unittest discover -s keepersdk-package/unit_tests/ | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Build the package | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| python3 -m pip install -U setuptools build wheel twine | |||||||||||||||||||||||||||||
| python3 -m pip install -U build wheel twine | |||||||||||||||||||||||||||||
| python3 -m build --wheel keepersdk-package | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Archive the package | |||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v3 | |||||||||||||||||||||||||||||
| uses: actions/upload-artifact@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| name: KeeperSdkWheel | |||||||||||||||||||||||||||||
| retention-days: 1 | |||||||||||||||||||||||||||||
| path: keepersdk-package/dist/* | |||||||||||||||||||||||||||||
| if-no-files-found: error | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Publish Commander to test PyPi | |||||||||||||||||||||||||||||
| publish-test-pypi: | |||||||||||||||||||||||||||||
| name: Publish to Test PyPI | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| needs: [build-and-test] | |||||||||||||||||||||||||||||
| environment: test | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - uses: actions/download-artifact@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| name: KeeperSdkWheel | |||||||||||||||||||||||||||||
| path: keepersdk-package/dist | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Set up Python 3.13 | |||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| python-version: '3.13' | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Publish to Test PyPI | |||||||||||||||||||||||||||||
| env: | |||||||||||||||||||||||||||||
| TWINE_USERNAME: __token__ | |||||||||||||||||||||||||||||
| TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| twine upload -r testpypi dist/* | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| python -m pip install -U twine | |||||||||||||||||||||||||||||
| twine upload --repository testpypi keepersdk-package/dist/* | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| publish-pypi: | |||||||||||||||||||||||||||||
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}
|
|||||||||||||||||||||||||||||
| name: Publish Keeper SDK to PyPi | |||||||||||||||||||||||||||||
| name: Publish to Production PyPI | |||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | |||||||||||||||||||||||||||||
| needs: [build-wheel] | |||||||||||||||||||||||||||||
| needs: [publish-test-pypi] | |||||||||||||||||||||||||||||
| environment: prod | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| steps: | |||||||||||||||||||||||||||||
| - uses: actions/download-artifact@v3 | |||||||||||||||||||||||||||||
| - uses: actions/download-artifact@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| name: CommanderWheel | |||||||||||||||||||||||||||||
| path: dist | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Set up Python 3.10 | |||||||||||||||||||||||||||||
| uses: actions/setup-python@v4 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| python-version: '3.11' | |||||||||||||||||||||||||||||
| name: KeeperSdkWheel | |||||||||||||||||||||||||||||
| path: keepersdk-package/dist | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Retrieve secrets from Keeper | |||||||||||||||||||||||||||||
| id: ksecrets | |||||||||||||||||||||||||||||
| uses: Keeper-Security/ksm-action@master | |||||||||||||||||||||||||||||
| - name: Set up Python 3.13 | |||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | |||||||||||||||||||||||||||||
| with: | |||||||||||||||||||||||||||||
| keeper-secret-config: ${{ secrets.KSM_COMMANDER_SECRET_CONFIG }} | |||||||||||||||||||||||||||||
| secrets: | | |||||||||||||||||||||||||||||
| gD5LOOhI5QbnSFk8mIg3gg/field/password > PYPI_PASSWORD | |||||||||||||||||||||||||||||
| python-version: '3.13' | |||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||
| - name: Publish to PyPi | |||||||||||||||||||||||||||||
| - name: Publish to PyPI | |||||||||||||||||||||||||||||
| env: | |||||||||||||||||||||||||||||
| TWINE_USERNAME: __token__ | |||||||||||||||||||||||||||||
| TWINE_PASSWORD: ${{ steps.ksecrets.outputs.PYPI_PASSWORD }} | |||||||||||||||||||||||||||||
| TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISH_TOKEN }} | |||||||||||||||||||||||||||||
| run: | | |||||||||||||||||||||||||||||
| python -m pip install -U setuptools pip wheel twine | |||||||||||||||||||||||||||||
| twine upload dist/* | |||||||||||||||||||||||||||||
| python -m pip install -U twine | |||||||||||||||||||||||||||||
| twine upload keepersdk-package/dist/* | |||||||||||||||||||||||||||||
|
Comment on lines
+68
to
+90
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 2 months ago To fix this problem, add a
Suggested changeset
1
.github/workflows/publish-sdk.yml
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
|||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,35 +1,36 @@ | ||
| name: Test with pytest | ||
| name: Test with unittest | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - masterlet' | ||
| - master | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| PYTHONUNBUFFERED: 1 | ||
|
|
||
| jobs: | ||
| test-with-pytest: | ||
| test-with-unittest: | ||
| strategy: | ||
| matrix: | ||
| python-version: ['3.8', '3.14'] | ||
|
|
||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
|
|
||
| steps: | ||
| - name: Checkout branch | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v4 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Install package with test dependencies | ||
| - name: Install package | ||
| run: | | ||
| cd keepersdk-package | ||
| pip install .[test] | ||
| pip install -e keepersdk-package/ | ||
|
|
||
| - name: Run unit tests | ||
| run: pytest keepersdk-package/unit_tests/ | ||
| run: python -m unittest discover -s keepersdk-package/unit_tests/ |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 2 months ago
To resolve the issue, add a
permissionsblock to thepublish-pypijob. This should grant only the minimal needed permission. In this case, there is no obvious use of the GITHUB_TOKEN for write access within thepublish-pypijob—there is no usage of actions that modify repository contents, releases, issues, etc. Therefore,contents: readis sufficient and aligns with least privilege. The change is to insert the following at the same indentation as other job keys underpublish-pypi:No other code or configuration changes are necessary. No imports or external dependencies are required.