Skip to content

Commit 0f34eb3

Browse files
authored
action: accommodate Windows (#72)
* action: accommodate Windows Signed-off-by: William Woodruff <[email protected]> * selftest: macOS, Windows Signed-off-by: William Woodruff <[email protected]> * selftest: explicit python version Needed for macOS, Windows (probably) Signed-off-by: William Woodruff <[email protected]> * action: force bash for action.py invocation as well Signed-off-by: William Woodruff <[email protected]> * Revert "action: force bash for action.py invocation as well" This reverts commit 1c3a332. * action: Windows force UTF-8 Signed-off-by: William Woodruff <[email protected]> * action: hackety hack Signed-off-by: William Woodruff <[email protected]> * action: random delim Signed-off-by: William Woodruff <[email protected]> * action: oops Signed-off-by: William Woodruff <[email protected]> * selftest: shell: bash Signed-off-by: William Woodruff <[email protected]> * ci: loosen python constraint Signed-off-by: William Woodruff <[email protected]> * action: use os.urandom Signed-off-by: William Woodruff <[email protected]> * action: document random delimiter Signed-off-by: William Woodruff <[email protected]> --------- Signed-off-by: William Woodruff <[email protected]>
1 parent dbe0a6f commit 0f34eb3

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
- uses: actions/checkout@v3
1414
- uses: actions/setup-python@v4
1515
with:
16-
python-version: "3.7"
16+
python-version: "3.x"
1717
- name: lint
1818
run: make lint

.github/workflows/selftest.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,27 @@ permissions:
1313

1414
jobs:
1515
selftest:
16-
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
os:
19+
- ubuntu-latest
20+
- macos-latest
21+
- windows-latest
22+
runs-on: ${{ matrix.os }}
1723
if: (github.event_name != 'pull_request') || !github.event.pull_request.head.repo.fork
1824
steps:
1925
- uses: actions/checkout@v3
26+
- uses: actions/setup-python@v4
27+
if: ${{ matrix.os != 'ubuntu-latest' }}
28+
with:
29+
python-version: "3.x"
2030
- name: Sign artifact and publish signature
2131
uses: ./
2232
id: sigstore-python
2333
with:
2434
inputs: ./test/artifact.txt
2535
- name: Check outputs
36+
shell: bash
2637
run: |
2738
[[ -f ./test/artifact.txt.sigstore ]] || exit 1
2839

action.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,16 @@ def _fatal_help(msg):
280280
with Path(_github_env).open("a") as gh_env:
281281
# Multiline values must match the following syntax:
282282
#
283-
# {name}<<{delimiter}
284-
# {value}
285-
# {delimiter}
286-
gh_env.write(
287-
"GHA_SIGSTORE_PYTHON_INTERNAL_SIGNING_ARTIFACTS<<EOF"
288-
+ os.linesep
289-
+ os.linesep.join(signing_artifact_paths)
290-
+ os.linesep
291-
+ "EOF"
292-
)
283+
# {name}<<{delimiter}
284+
# {value}
285+
# {delimiter}
286+
#
287+
# We use a random delimiter to avoid potential conflicts with our input;
288+
# see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions
289+
delim = os.urandom(16).hex()
290+
print(f"GHA_SIGSTORE_PYTHON_INTERNAL_SIGNING_ARTIFACTS<<{delim}", file=gh_env)
291+
print("\n".join(signing_artifact_paths), file=gh_env)
292+
print(delim, file=gh_env)
293293

294294

295295
# If signing didn't fail, then we check the verification status, if present.

action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,16 @@ runs:
101101
- name: Set up sigstore-python
102102
run: |
103103
# NOTE: Sourced, not executed as a script.
104-
source "${{ github.action_path }}/setup/setup.bash"
104+
source "${GITHUB_ACTION_PATH}/setup/setup.bash"
105105
shell: bash
106106

107107
- name: Run sigstore-python
108108
id: sigstore-python
109109
run: |
110-
${{ github.action_path }}/action.py "${{ inputs.inputs }}"
110+
${GITHUB_ACTION_PATH}/action.py "${GHA_SIGSTORE_PYTHON_INPUTS}"
111111
env:
112+
# The year is 2023, and nonsense like this is still necessary on Windows.
113+
PYTHONUTF8: "1"
112114
GHA_SIGSTORE_PYTHON_IDENTITY_TOKEN: "${{ inputs.identity-token }}"
113115
GHA_SIGSTORE_PYTHON_SIGNATURE: "${{ inputs.signature }}"
114116
GHA_SIGSTORE_PYTHON_CERTIFICATE: "${{ inputs.certificate }}"
@@ -125,6 +127,7 @@ runs:
125127
GHA_SIGSTORE_PYTHON_VERIFY_OIDC_ISSUER: "${{ inputs.verify-oidc-issuer }}"
126128
GHA_SIGSTORE_PYTHON_RELEASE_SIGNING_ARTIFACTS: "${{ inputs.release-signing-artifacts }}"
127129
GHA_SIGSTORE_PYTHON_INTERNAL_BE_CAREFUL_DEBUG: "${{ inputs.internal-be-careful-debug }}"
130+
GHA_SIGSTORE_PYTHON_INPUTS: "${{ inputs.inputs }}"
128131
shell: bash
129132

130133
- uses: actions/upload-artifact@v3

0 commit comments

Comments
 (0)