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
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,23 @@ permissions:
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Validate required action gate
run: bash tests/validate-action.sh

platform:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Validate action structure
if: runner.os != 'Windows'
run: bash tests/validate-action.sh
- name: Validate Windows runner script
if: runner.os == 'Windows'
shell: pwsh
run: ./tests/validate-action.ps1
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Added platform-aware acquisition for Linux, macOS, and Windows release archives, including a non-extracting PowerShell ZIP path.
- Added a manual post-release Action E2E workflow that consumes an explicit public core version and asserts the generated report and expected verifier outcome.
- Extended the offline Action regression suite to assert that a nonzero core verifier status is propagated.
- Refreshed project status to record the public v0.1.2 core release and the passing live Action end-to-end validation.
Expand Down
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
Expand Down Expand Up @@ -171,3 +174,28 @@
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include the
brackets!) The text should be enclosed in the appropriate comment
syntax for the file format. We also recommend that a file or class
name and description of purpose be included on the same "printed page"
as the copyright notice for easier identification within third-party
archives.

Copyright [yyyy] [name of copyright owner]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The Action invokes a released ReleaseCheck core binary. It does not reimplement

The Action's CI passes. ReleaseCheck `v0.1.2` is publicly released, and the manual [Action E2E workflow](.github/workflows/e2e.yml) has passed against that exact core release. The workflow run is recorded in the core repository's release documentation. This repository remains Ubuntu-oriented until tested platform-specific acquisition is added.

The initial integration supports Ubuntu runners with Bash, `curl`, `tar`, and `sha256sum`. Windows and macOS runner support should be added only with tested platform-specific acquisition behavior.
The Action supports Ubuntu and macOS runners through Bash plus Windows runners through PowerShell. Linux/macOS use `curl`, `tar`, and SHA-256 tooling; Windows uses PowerShell HTTPS, SHA-256, and ZIP APIs. Supported release targets are Linux amd64/arm64, macOS amd64/arm64, and Windows amd64.

## Usage

Expand All @@ -32,7 +32,7 @@ jobs:
output: releasecheck.sarif
```

The `releasecheck-version` input is required and must be an explicit semantic version. The Action downloads the matching Linux amd64 archive from the core release and verifies its SHA-256 checksum before execution. The public v0.1.2 core release has been exercised through the Action E2E workflow; pin a reviewed Action commit for production use.
The `releasecheck-version` input is required and must be an explicit semantic version. The Action selects the matching archive for the runner platform and verifies its SHA-256 checksum before execution. The public v0.1.2 core release has been exercised through the Action E2E workflow; pin a reviewed Action commit for production use.

Inputs:

Expand Down
14 changes: 14 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ runs:
using: composite
steps:
- id: verify
if: runner.os != 'Windows'
shell: bash
env:
INPUT_ECOSYSTEM: ${{ inputs.ecosystem }}
Expand All @@ -48,3 +49,16 @@ runs:
INPUT_OUTPUT: ${{ inputs.output }}
INPUT_FORMAT: ${{ inputs.format }}
run: bash "${{ github.action_path }}/scripts/run-releasecheck.sh"
- id: verify-windows
if: runner.os == 'Windows'
shell: pwsh
env:
INPUT_ECOSYSTEM: ${{ inputs.ecosystem }}
INPUT_PACKAGE: ${{ inputs.package }}
INPUT_VERSION: ${{ inputs.version }}
INPUT_ARTIFACT: ${{ inputs.artifact }}
INPUT_TIMEOUT: ${{ inputs.timeout }}
INPUT_RELEASECHECK_VERSION: ${{ inputs.releasecheck-version }}
INPUT_OUTPUT: ${{ inputs.output }}
INPUT_FORMAT: ${{ inputs.format }}
run: '& "${{ github.action_path }}\scripts\run-releasecheck.ps1"'
74 changes: 74 additions & 0 deletions scripts/run-releasecheck.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

function Fail([string]$Message, [int]$Code = 1) {
[Console]::Error.WriteLine($Message)
exit $Code
}

$version = $env:INPUT_RELEASECHECK_VERSION
if ([string]::IsNullOrWhiteSpace($version)) { Fail 'releasecheck-version is required' 2 }
if ($version -notmatch '^[0-9]+\.[0-9]+\.[0-9]+$') { Fail "releasecheck-version must match MAJOR.MINOR.PATCH: $version" 2 }

if ($env:INPUT_ECOSYSTEM -notin @('npm', 'pypi')) { Fail 'ecosystem must be npm or pypi' 2 }
if ($env:INPUT_FORMAT -notin @('human', 'json', 'sarif')) { Fail 'format must be human, json, or sarif' 2 }
if ([string]::IsNullOrWhiteSpace($env:GITHUB_WORKSPACE)) { Fail 'GITHUB_WORKSPACE is required' 2 }
if ([string]::IsNullOrWhiteSpace($env:GITHUB_OUTPUT)) { Fail 'GITHUB_OUTPUT is required' 2 }

$output = if ([string]::IsNullOrWhiteSpace($env:INPUT_OUTPUT)) { 'releasecheck-report.json' } else { $env:INPUT_OUTPUT }
if ($output -match '(^|[\\/])\.\.(?:[\\/]|$)' -or [IO.Path]::IsPathRooted($output)) { Fail 'output must stay within the workspace' 2 }
$outputPath = Join-Path $env:GITHUB_WORKSPACE $output
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $outputPath) | Out-Null

$cacheDir = Join-Path $(if ([string]::IsNullOrWhiteSpace($env:RUNNER_TEMP)) { $env:GITHUB_WORKSPACE } else { $env:RUNNER_TEMP }) 'releasecheck'
New-Item -ItemType Directory -Force -Path $cacheDir | Out-Null
$base = "https://github.com/ReleaseCheck/releasecheck/releases/download/v$version"
$archive = "releasecheck-v$version-windows-amd64.zip"
$archiveFile = Join-Path $cacheDir $archive
$checksumFile = Join-Path $cacheDir 'SHA256SUMS'
$binaryDir = Join-Path $cacheDir "releasecheck-v$version-windows-amd64"
$binary = Join-Path $binaryDir 'releasecheck.exe'
$archiveBinary = "releasecheck-v$version-windows-amd64/releasecheck.exe"

if (-not (Test-Path -LiteralPath $binary)) {
Invoke-WebRequest -Uri "$base/SHA256SUMS" -OutFile $checksumFile -UseBasicParsing
Invoke-WebRequest -Uri "$base/$archive" -OutFile $archiveFile -UseBasicParsing

$matches = @(
Get-Content -LiteralPath $checksumFile | ForEach-Object {
if ($_ -match '^([0-9A-Fa-f]{64})\s+\*?\.?/?(.+?)\s*$') {
if ($Matches[2] -eq $archive) { $Matches[1].ToLowerInvariant() }
}
}
)
if ($matches.Count -ne 1) { Fail 'archive checksum is missing, malformed, or ambiguous' }
$actual = (Get-FileHash -Algorithm SHA256 -LiteralPath $archiveFile).Hash.ToLowerInvariant()
if ($actual -ne $matches[0]) { Fail 'archive checksum mismatch' }

Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = [IO.Compression.ZipFile]::OpenRead($archiveFile)
try {
$entry = $zip.Entries | Where-Object { $_.FullName -eq $archiveBinary }
if ($null -eq $entry -or $entry.Count -ne 1 -or $entry[0].Length -le 0 -or $entry[0].Length -gt 100MB) {
Fail 'release archive does not contain one bounded Windows binary'
}
New-Item -ItemType Directory -Force -Path $binaryDir | Out-Null
$temporaryBinary = Join-Path $binaryDir '.releasecheck.tmp'
$input = $entry[0].Open()
$outputStream = [IO.File]::Open($temporaryBinary, [IO.FileMode]::CreateNew, [IO.FileAccess]::Write, [IO.FileShare]::None)
try { $input.CopyTo($outputStream) } finally { $outputStream.Dispose(); $input.Dispose() }
Move-Item -LiteralPath $temporaryBinary -Destination $binary -Force
} finally { $zip.Dispose() }
}

$args = @('verify', $env:INPUT_ECOSYSTEM)
if ($env:INPUT_FORMAT -eq 'json') { $args += '--json' }
if ($env:INPUT_FORMAT -eq 'sarif') { $args += '--sarif' }
$args += @('--timeout', $(if ([string]::IsNullOrWhiteSpace($env:INPUT_TIMEOUT)) { '30s' } else { $env:INPUT_TIMEOUT }), '--output', $outputPath, $env:INPUT_PACKAGE)
if (-not [string]::IsNullOrWhiteSpace($env:INPUT_VERSION)) { $args += $env:INPUT_VERSION }
if ($env:INPUT_ECOSYSTEM -eq 'pypi' -and -not [string]::IsNullOrWhiteSpace($env:INPUT_ARTIFACT)) { $args += @('--artifact', $env:INPUT_ARTIFACT) }

& $binary @args
$status = $LASTEXITCODE
Add-Content -LiteralPath $env:GITHUB_OUTPUT -Value "report=$output"
exit $status
18 changes: 14 additions & 4 deletions scripts/run-releasecheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ mkdir -p "$GITHUB_WORKSPACE/$(dirname "$output")"
cache_dir="${RUNNER_TEMP:-$GITHUB_WORKSPACE}/releasecheck"
mkdir -p "$cache_dir"
base="https://github.com/ReleaseCheck/releasecheck/releases/download/v${version}"
archive="releasecheck-v${version}-linux-amd64.tar.gz"
case "${RUNNER_OS:-Linux}:${RUNNER_ARCH:-X64}" in
Linux:X64) archive="releasecheck-v${version}-linux-amd64.tar.gz" ;;
Linux:ARM64) archive="releasecheck-v${version}-linux-arm64.tar.gz" ;;
macOS:X64) archive="releasecheck-v${version}-darwin-amd64.tar.gz" ;;
macOS:ARM64) archive="releasecheck-v${version}-darwin-arm64.tar.gz" ;;
*) echo "unsupported runner platform: ${RUNNER_OS:-unknown}/${RUNNER_ARCH:-unknown}" >&2; exit 2 ;;
esac
checksum_file="$cache_dir/SHA256SUMS"
archive_file="$cache_dir/$archive"
binary_dir="$cache_dir/releasecheck-v${version}-linux-amd64"
binary_dir="$cache_dir/${archive%.tar.gz}"
binary="$binary_dir/releasecheck"
archive_binary="releasecheck-v${version}-linux-amd64/releasecheck"
archive_binary="${archive%.tar.gz}/releasecheck"

if [[ ! -x "$binary" ]]; then
curl --fail --location --proto '=https' --tlsv1.2 --silent --show-error "$base/SHA256SUMS" -o "$checksum_file"
Expand All @@ -61,7 +67,11 @@ if [[ ! -x "$binary" ]]; then
expected=""
fi
if [[ -z "$expected" ]]; then echo "archive checksum is missing, malformed, or ambiguous" >&2; exit 1; fi
actual="$(sha256sum "$archive_file" | awk '{print $1}')"
if command -v sha256sum >/dev/null 2>&1; then
actual="$(sha256sum "$archive_file" | awk '{print $1}')"
else
actual="$(shasum -a 256 "$archive_file" | awk '{print $1}')"
fi
if [[ "$actual" != "$expected" ]]; then echo "archive checksum mismatch" >&2; exit 1; fi
mkdir -p "$binary_dir"
temporary_binary="$binary_dir/.releasecheck.tmp"
Expand Down
23 changes: 23 additions & 0 deletions tests/validate-action.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest

foreach ($path in @('action.yml', 'LICENSE', 'scripts/run-releasecheck.ps1')) {
if (-not (Test-Path -LiteralPath $path)) { throw "missing required file: $path" }
}

$action = Get-Content -Raw action.yml
foreach ($needle in @('using: composite', "runner.os == 'Windows'", 'run-releasecheck.ps1', 'releasecheck-version')) {
if ($action -notlike "*$needle*") { throw "action.yml is missing: $needle" }
}

$scriptPath = (Resolve-Path scripts/run-releasecheck.ps1).Path
$tokens = $null
$errors = $null
[System.Management.Automation.Language.Parser]::ParseFile($scriptPath, [ref]$tokens, [ref]$errors) | Out-Null
if ($errors.Count -gt 0) { throw "PowerShell script parse errors: $($errors | Out-String)" }
$script = Get-Content -Raw $scriptPath
foreach ($needle in @('Get-FileHash', 'ZipFile', 'GITHUB_OUTPUT', 'releasecheck.exe')) {
if ($script -notlike "*$needle*") { throw "Windows runner script is missing: $needle" }
}
if ($script -match 'npm install|pip install|Invoke-Expression|iex\s') { throw 'unsafe package installation or dynamic execution found' }
Write-Output 'windows-action-structure=PASS'
5 changes: 5 additions & 0 deletions tests/validate-action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ set -euo pipefail
test -f action.yml
test -f LICENSE
test -f scripts/run-releasecheck.sh
test -f scripts/run-releasecheck.ps1
grep -q 'using: composite' action.yml
grep -q 'releasecheck-version' action.yml
grep -q 'description: "Registry ecosystem to verify: npm or pypi"' action.yml
grep -q 'description: "Report format: human, json, or sarif"' action.yml
grep -q 'sha256sum' scripts/run-releasecheck.sh
grep -q 'tar -xOzf' scripts/run-releasecheck.sh
grep -q 'verify' scripts/run-releasecheck.sh
grep -q "runner.os == 'Windows'" action.yml
grep -q 'run-releasecheck.ps1' action.yml
if grep -Eq 'npm install|pip install|curl.*\|.*sh|eval ' scripts/run-releasecheck.sh; then
echo 'unsafe installation or shell execution found' >&2
exit 1
Expand Down Expand Up @@ -65,6 +68,8 @@ run_action() {
MOCK_RELEASE_DIR="$release_dir" \
GITHUB_WORKSPACE="$workspace" \
RUNNER_TEMP="$test_root/runner" \
RUNNER_OS=Linux \
RUNNER_ARCH=X64 \
GITHUB_OUTPUT="$test_root/github-output" \
INPUT_ECOSYSTEM=npm \
INPUT_PACKAGE=example-package \
Expand Down
Loading