Skip to content

Commit

Permalink
feat(versioned-files-action): Create action
Browse files Browse the repository at this point in the history
  • Loading branch information
tomphp committed Oct 24, 2023
1 parent cff0561 commit 5b6638b
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,46 @@ jobs:
- uses: actions/checkout@v4
- uses: ./github-actions/setup-versioned-files
- run: versioned-files --version

test-setup-versioned-files-with-specific-version:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: ./github-actions/setup-versioned-files
with:
version: 0.3.0
- run: versioned-files --version | grep 0.3.0

test-versioned-files-update:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
path: repo
- name: Create Example File
shell: bash
run: echo "The current version is 1.2.3" >example.txt
- name: Create versioned-files.yml
shell: bash
run: |
cat <<EOF | tee versioned-files.yml
locations:
- !string-pattern
file: example.txt
pattern: version is {{version}}
EOF
- uses: ./repo/github-actions/versioned-files
with:
action: update
version: 1.3.0
- name: Check files has been substituted
shell: bash
run: |
cat example.txt
grep "The current version is 1.3.0" example.txt
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ versioned-files --version
```

```text, verify()
versioned-files 0.2.2
versioned-files 0.3.0
```

## Configuration
Expand Down
5 changes: 3 additions & 2 deletions github-actions/setup-versioned-files/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ outputs:
runs:
using: composite
steps:
- uses: tomphp/github-actions/install-release-binary@v0.5.0
- name: Install versioned-files
uses: tomphp/github-actions/install-release-binary@v0.5.0
with:
binary-name: versioned-files
owner: tomphp
repository: versioned-files
version: ${{ inputs.version }}

- name: Install versioned-files
- name: Get Installed Version
id: get-version
run: |
echo "version=$( versioned-files --version | cut -d " " -f2 )" >> "$GITHUB_OUTPUT"
Expand Down
34 changes: 34 additions & 0 deletions github-actions/versioned-files/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Runs versioned-files
description: Runs versioned-files

inputs:
action:
description: The versioned-files action to run
required: true
version:
description: The version to update to
required: true

runs:
using: composite
steps:
- uses: tomphp/versioned-files/github-actions/setup-versioned-files@v0.3.0
name: Install versioned-files
with:
version: 0.3.0

- name: Run versioned-files
id: get-version
env:
ACTION: ${{ inputs.action }}
VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
if [ "$ACTION" == "update" ]; then
versioned-files update "$VERSION"
else
echo "Unknown action '$ACTION'" >&2
exit 1
fi
shell: bash

0 comments on commit 5b6638b

Please sign in to comment.