Skip to content
Closed
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
14 changes: 14 additions & 0 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Run

on: workflow_dispatch

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: ./assert-version
with:
filename: fixtures/assert-version/binary.sh
expected-version: "1.2.3"
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI

on:
push:
pull_request:

jobs:
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"
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test:
act -W .github/workflows/test.yml

run:
act -W .github/workflows/run.yml
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 4 additions & 0 deletions fixtures/assert-version/binary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
if [[ "$1" == "--version" ]]; then
echo "myapp 1.2.3"
fi
7 changes: 1 addition & 6 deletions release-tag-to-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down Expand Up @@ -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<<EOF"
Expand Down
Loading