From ff03f6aba76cdc5d020c48f330d227895a901825 Mon Sep 17 00:00:00 2001 From: Propfend Date: Fri, 27 Mar 2026 13:05:34 +0100 Subject: [PATCH 1/4] create a tag so tests use it. --- .github/workflows/run.yml | 31 +++++++++++ .github/workflows/test.yml | 106 +++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 .github/workflows/run.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml new file mode 100644 index 0000000..b87e483 --- /dev/null +++ b/.github/workflows/run.yml @@ -0,0 +1,31 @@ +name: Run + +on: workflow_dispatch + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: create test tag + run: | + git config user.name "test" + git config user.email "test@test.com" + git tag -a v1.2.3 -m "Release 1.2.3" + git remote set-url origin "file://$(pwd)/.git" + + - uses: ./release-tag-to-version + id: release + with: + release-tag: v1.2.3 + + - name: print outputs + run: | + echo "type: ${{ steps.release.outputs.type }}" + echo "version: ${{ steps.release.outputs.version }}" + + - uses: ./assert-version + with: + filename: fixtures/assert-version/binary.sh + expected-version: ${{ steps.release.outputs.version }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4eceba7 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,106 @@ +name: CI + +on: + push: + pull_request: + +jobs: + test-release-tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: create test tag + run: | + git config user.name "test" + git config user.email "test@test.com" + git tag -a v1.2.3 -m "Release 1.2.3" + git remote set-url origin "file://$(pwd)/.git" + + - uses: ./release-tag-to-version + id: release + with: + release-tag: v1.2.3 + + - name: assert type is RELEASE + run: test "${{ steps.release.outputs.type }}" = "RELEASE" + + - name: assert version is 1.2.3 + run: test "${{ steps.release.outputs.version }}" = "1.2.3" + + test-prerelease-tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: create test tag + run: | + git config user.name "test" + git config user.email "test@test.com" + git tag -a v2.0.0-rc1 -m "Pre-release 2.0.0-rc1" + git remote set-url origin "file://$(pwd)/.git" + + - uses: ./release-tag-to-version + id: prerelease + with: + release-tag: v2.0.0-rc1 + + - name: assert type is PRE_RELEASE + run: test "${{ steps.prerelease.outputs.type }}" = "PRE_RELEASE" + + - name: assert version is 2.0.0 + run: test "${{ steps.prerelease.outputs.version }}" = "2.0.0" + + test-invalid-tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./release-tag-to-version + id: invalid + continue-on-error: true + with: + release-tag: not-a-tag + + - name: assert invalid tag fails + run: test "${{ steps.invalid.outcome }}" = "failure" + + test-assert-version-match: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./assert-version + with: + filename: fixtures/assert-version/binary.sh + expected-version: "1.2.3" + + test-assert-version-mismatch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./assert-version + id: mismatch + continue-on-error: true + with: + filename: fixtures/assert-version/binary.sh + expected-version: "3.2.1" + + - name: assert mismatch fails + run: test "${{ steps.mismatch.outcome }}" = "failure" + + test-assert-version-invalid: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: ./assert-version + id: invalid + continue-on-error: true + with: + filename: fixtures/assert-version/binary.sh + expected-version: "not-a-version" + + - name: assert invalid version fails + run: test "${{ steps.invalid.outcome }}" = "failure" From 055c026fa164550545021114fec0f8e3c0bd0da0 Mon Sep 17 00:00:00 2001 From: Propfend Date: Fri, 27 Mar 2026 13:18:11 +0100 Subject: [PATCH 2/4] fix the workflow so it works. --- Makefile | 5 ++++ README.md | 42 ++++++++++++++++++++++++++++--- fixtures/assert-version/binary.sh | 4 +++ 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 Makefile create mode 100755 fixtures/assert-version/binary.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..69ab195 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +test: + act -W .github/workflows/test.yml + +run: + act -W .github/workflows/run.yml diff --git a/README.md b/README.md index 258b7d7..5e80170 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,40 @@ -Opinionated actions for GitHub releases +# release-action -- release-tag-to-version: Get the tag from commit, validates and pushes to release. -- assert-version: Validates if the tag pushed to repository is same as the one in project. +GitHub actions for validating and extracting release information from Git tags. + +### `release-tag-to-version` + +Validates a release tag (`v1.2.3` or `v1.2.3-rc1`), extracts the semantic version. Outputs `type` (RELEASE/PRE_RELEASE) and `version`. + +### Usage + +```yml +- uses: intentee/release-action/release-tag-to-version@main + id: release + with: + release-tag: ${{ github.ref_name }} +``` + +### `assert-version` + +Runs artifact with `--version` flag and asserts the output contains the expected semantic version. + +### Usage + +```yml +- uses: intentee/release-action/assert-version@main + with: + filename: target/release/myapp + expected-version: ${{ steps.release.outputs.version }} +``` + +### Commands + +#### `make run`: +- Runs both actions against `fixtures` via [`act`](https://github.com/nektos/act). +- Requires Docker. + +#### `make test`: +- Runs `.github/workflows/test.yml` locally via [`act`](https://github.com/nektos/act). +- Asserts valid tags, invalid tags, version match, mismatch, and invalid version format. +- Requires Docker. diff --git a/fixtures/assert-version/binary.sh b/fixtures/assert-version/binary.sh new file mode 100755 index 0000000..c1168ec --- /dev/null +++ b/fixtures/assert-version/binary.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +if [[ "$1" == "--version" ]]; then + echo "myapp 1.2.3" +fi From a2f3941f01f688a7abb4789b9699c2140e9a0f27 Mon Sep 17 00:00:00 2001 From: Propfend Date: Fri, 27 Mar 2026 17:43:28 +0100 Subject: [PATCH 3/4] remove the tests which need a real repo tag to work. --- .github/workflows/run.yml | 19 +--------------- .github/workflows/test.yml | 46 -------------------------------------- 2 files changed, 1 insertion(+), 64 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index b87e483..928b50c 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -8,24 +8,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: create test tag - run: | - git config user.name "test" - git config user.email "test@test.com" - git tag -a v1.2.3 -m "Release 1.2.3" - git remote set-url origin "file://$(pwd)/.git" - - - uses: ./release-tag-to-version - id: release - with: - release-tag: v1.2.3 - - - name: print outputs - run: | - echo "type: ${{ steps.release.outputs.type }}" - echo "version: ${{ steps.release.outputs.version }}" - - uses: ./assert-version with: filename: fixtures/assert-version/binary.sh - expected-version: ${{ steps.release.outputs.version }} + expected-version: "1.2.3" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4eceba7..350f754 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,52 +5,6 @@ on: pull_request: jobs: - test-release-tag: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: create test tag - run: | - git config user.name "test" - git config user.email "test@test.com" - git tag -a v1.2.3 -m "Release 1.2.3" - git remote set-url origin "file://$(pwd)/.git" - - - uses: ./release-tag-to-version - id: release - with: - release-tag: v1.2.3 - - - name: assert type is RELEASE - run: test "${{ steps.release.outputs.type }}" = "RELEASE" - - - name: assert version is 1.2.3 - run: test "${{ steps.release.outputs.version }}" = "1.2.3" - - test-prerelease-tag: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: create test tag - run: | - git config user.name "test" - git config user.email "test@test.com" - git tag -a v2.0.0-rc1 -m "Pre-release 2.0.0-rc1" - git remote set-url origin "file://$(pwd)/.git" - - - uses: ./release-tag-to-version - id: prerelease - with: - release-tag: v2.0.0-rc1 - - - name: assert type is PRE_RELEASE - run: test "${{ steps.prerelease.outputs.type }}" = "PRE_RELEASE" - - - name: assert version is 2.0.0 - run: test "${{ steps.prerelease.outputs.version }}" = "2.0.0" - test-invalid-tag: runs-on: ubuntu-latest steps: From 1388988693774c66569478f7dddd8d391dc5c406 Mon Sep 17 00:00:00 2001 From: Propfend Date: Fri, 27 Mar 2026 18:31:07 +0100 Subject: [PATCH 4/4] the description is used as the body, title is the version of tag. --- release-tag-to-version/action.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/release-tag-to-version/action.yml b/release-tag-to-version/action.yml index 14023b5..08aad0c 100644 --- a/release-tag-to-version/action.yml +++ b/release-tag-to-version/action.yml @@ -9,8 +9,6 @@ outputs: value: ${{ steps.tag-type.outputs.tag-type }} version: value: ${{ steps.set-release-version.outputs.release-version }} - name: - value: ${{ steps.tag-message.outputs.name }} description: value: ${{ steps.tag-message.outputs.description }} @@ -56,10 +54,7 @@ runs: - name: Extract tag message id: tag-message run: | - NAME=$(git tag -l --format='%(contents:subject)' "$RELEASE_TAG") - DESCRIPTION=$(git tag -l --format='%(contents:body)' "$RELEASE_TAG") - - echo "name=${NAME}" >> $GITHUB_OUTPUT + DESCRIPTION=$(git tag -l --format='%(contents)' "$RELEASE_TAG") { echo "description<