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
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ jobs:
task-retries: '3'
setup-gomplate: true
setup-jq: true
setup-semver: true

- name: Verify Setup
run: |
Expand Down Expand Up @@ -124,6 +125,9 @@ jobs:
echo "::group::Verify JQ Installation"
jq --version
echo "::endgroup::"
echo "::group::Verify SemVer Installation"
semver --version
echo "::endgroup::"

test-egress-policy:
name: Test Egress Policy Input
Expand Down Expand Up @@ -523,3 +527,33 @@ jobs:
echo "Expected jq version ${EXPECTED_VERSION}, got: ${ACTUAL}"
exit 1
fi

test-setup-semver:
name: Test Setup SemVer Tools
runs-on: ubuntu-latest
steps:
- name: Harden Runner
id: harden-runner
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit

- name: Checkout Repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Run Setup Semver
id: test-setup-semver
uses: ./
with:
setup-semver: true

- name: Verify SemVer Installation
run: |
INSTALLED_VERSION="$(semver --version)"
OUTPUT_VERSION="${{ steps.test-setup-semver.outputs.semver-version }}"
echo "semver reported: ${INSTALLED_VERSION}"
echo "semver output: ${OUTPUT_VERSION}"
if [[ "${INSTALLED_VERSION}" != "${OUTPUT_VERSION}" ]]; then
echo "Expected semver version ${OUTPUT_VERSION}, got: ${INSTALLED_VERSION}"
exit 1
fi
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@ Common steps for initializing a job for GitHub actions. This composite action co
> binary itself is the exact requested version, but the reported version
> string cannot distinguish 1.7.0 from 1.7.1.

**SemVer**

| Input | Description | Required | Default |
|--------------|---------------------------------|----------|---------|
| setup-semver | Whether to setup semver | No | false |

> [!NOTE]
> `setup-semver` downloads the semver script directly from
> https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
> and installs it to `/usr/local/bin/semver`.

### Outputs

**Checkout Outputs**
Expand Down Expand Up @@ -198,6 +209,10 @@ Common steps for initializing a job for GitHub actions. This composite action co
- `swift-toolchain`: JSON formatted toolchain snapshot metadata
- `swift-sdks`: JSON formatted SDK snapshots metadata

**SemVer Outputs**

- `semver-version`: The installed semver version

## Examples

**Node.js Project**
Expand Down Expand Up @@ -246,6 +261,7 @@ Common steps for initializing a job for GitHub actions. This composite action co
setup-python: 'true'
python-version: '3.12'
python-cache: 'pip'
setup-semver: 'true'
```

**Blocking Egress Traffic**
Expand Down
27 changes: 27 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ inputs:
description: 'Desired jq version (e.g. 1.8.1)'
required: false
default: '1.8.1'
setup-semver:
description: 'Whether to setup semver tool'
required: false
Comment thread
rbarker-dev marked this conversation as resolved.
default: 'false'

# expose outputs from the sub-actions
outputs:
Expand Down Expand Up @@ -232,6 +236,9 @@ outputs:
swift-sdks:
description: 'JSON formatted SDK snapshots metadata that were configured.'
value: ${{ steps.setup-swift.outputs.sdks }}
semver-version:
description: 'The installed semver version.'
value: ${{ steps.setup-semver.outputs.version }}

runs:
using: 'composite'
Expand Down Expand Up @@ -540,6 +547,26 @@ runs:
jq --version
echo "::endgroup::"

- name: Setup Semver
id: setup-semver
if: ${{ inputs.setup-semver == 'true' }}
shell: bash
run: |
echo "::group::Download SemVer Binary"
sudo curl -sSfL https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver \
-o /tmp/semver || { echo "Failed to download semver binary"; exit 1; }
echo "::endgroup::"

echo "::group::Change SemVer Binary Permissions"
sudo install -m 755 /tmp/semver /usr/local/bin/semver
echo "::endgroup::"

echo "::group::Show SemVer Binary Version Info"
VERSION="$(/usr/local/bin/semver --version | tr -d '\n')"
echo "semver version: ${VERSION}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
echo "::endgroup::"

branding:
icon: 'arrow-up-right'
color: 'green'
Loading