-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dafyddj/feat/initial
feat: initial version of `copier-github-action`
- Loading branch information
Showing
23 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY | ||
_commit: v2.0.5 | ||
_src_path: gh:dafyddj/copier-bootstrap | ||
template_name: copier-github-action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"enabledManagers": [ | ||
"custom.regex", | ||
"git-submodules", | ||
], | ||
"extends": [ | ||
"config:recommended", | ||
], | ||
// `copier` template updates | ||
// There are two conditions that we need to account for | ||
// * a "clean" `.copier-answers.yml` file | ||
// * update needed but not yet applied (and further updates could appear in this condition) | ||
// `renovate` needs to be able to match both conditions for PRs to work properly | ||
// We make a hacky use of the otherwise unused field `currentDigest` to hold the current copier template version | ||
"customManagers": [ | ||
{ | ||
"customType": "regex", | ||
"fileMatch": ["^.copier-answers.yml$"], | ||
"matchStrings": [ | ||
"_commit: (?<currentValue>\\S+)\\n_src_path: gh:(?<depName>\\S+)\\n", | ||
"_commit: (?<currentDigest>\\S+) # __copier_update_needed (?<currentValue>\\S+)\\n_src_path: gh:(?<depName>\\S+)\\n", | ||
], | ||
"datasourceTemplate": "github-tags", | ||
"autoReplaceStringTemplate": "_commit: {{#if currentDigest}}{{{currentDigest}}}{{else}}{{{currentValue}}}{{/if}} # __copier_update_needed {{{newValue}}}\n_src_path: gh:{{{depName}}}\n", | ||
}, | ||
], | ||
"git-submodules": { | ||
"enabled": true | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: Test & release | ||
|
||
on: | ||
pull_request: | ||
push: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }} | ||
|
||
jobs: | ||
pre-commit: | ||
name: Run `pre-commit` | ||
runs-on: ubuntu-latest | ||
env: | ||
# renovate: datasource=github-releases depName=actions/python-versions extractVersion=^(?<version>\S+)-\d+$ | ||
PYTHON_VERSION: 3.12.3 | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 | ||
test: | ||
name: Run approval tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
fetch-depth: 0 # `copier` prefers full-history clones | ||
submodules: true | ||
- name: Debug on runner (When re-run with "Enable debug logging" checked) | ||
if: runner.debug | ||
uses: mxschmitt/action-tmate@b3db6e16e597d92037c8647e54acc5d2b1b48dee # v3.18 | ||
with: | ||
detached: true | ||
- name: Install test dependencies | ||
run: | | ||
pipx install copier | ||
pipx install texttest | ||
- name: Run `texttest` | ||
run: texttest -b | ||
results: | ||
name: Collect results | ||
needs: | ||
- pre-commit | ||
- test | ||
permissions: | ||
contents: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: codfish/semantic-release-action@b0e57c976bf8f74b2454f59a30e4a1b5f11727b4 # v3.3.0 | ||
with: | ||
plugins: | | ||
[ "@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/github" | ||
] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "base"] | ||
path = base | ||
url = https://github.com/dafyddj/base-github-action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-merge-conflict | ||
args: [--assume-in-merge] | ||
- id: check-yaml | ||
- repo: https://github.com/python-jsonschema/check-jsonschema | ||
rev: 0.28.2 | ||
hooks: | ||
- id: check-github-workflows | ||
name: Check GitHub workflows with check-jsonschema | ||
args: ["--verbose"] | ||
- id: check-renovate | ||
name: Check Renovate config with check-jsonschema | ||
additional_dependencies: [json5==0.9.14] | ||
args: ["--verbose"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Check if the copier binary exists | ||
if ! [ -x "$(command -v copier)" ]; then | ||
echo "Error: 'copier' binary not found or not executable" | ||
exit 1 | ||
fi | ||
|
||
# Call the copier binary with all command line arguments | ||
copier "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_subdirectory: template | ||
_templates_suffix: .copier-jinja |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"enabledManagers": [ | ||
"custom.regex", | ||
"git-submodules", | ||
], | ||
"extends": [ | ||
"config:recommended", | ||
], | ||
// `copier` template updates | ||
// There are two conditions that we need to account for | ||
// * a "clean" `.copier-answers.yml` file | ||
// * update needed but not yet applied (and further updates could appear in this condition) | ||
// `renovate` needs to be able to match both conditions for PRs to work properly | ||
// We make a hacky use of the otherwise unused field `currentDigest` to hold the current copier template version | ||
"customManagers": [ | ||
{ | ||
"customType": "regex", | ||
"fileMatch": ["^.copier-answers.yml$"], | ||
"matchStrings": [ | ||
"_commit: (?<currentValue>\\S+)\\n_src_path: gh:(?<depName>\\S+)\\n", | ||
"_commit: (?<currentDigest>\\S+) # __copier_update_needed (?<currentValue>\\S+)\\n_src_path: gh:(?<depName>\\S+)\\n", | ||
], | ||
"datasourceTemplate": "github-tags", | ||
"autoReplaceStringTemplate": "_commit: {{#if currentDigest}}{{{currentDigest}}}{{else}}{{{currentValue}}}{{/if}} # __copier_update_needed {{{newValue}}}\n_src_path: gh:{{{depName}}}\n", | ||
}, | ||
], | ||
"git-submodules": { | ||
"enabled": true | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
name: Main | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
pre-commit: | ||
name: Run `pre-commit` | ||
runs-on: ubuntu-latest | ||
env: | ||
# renovate: datasource=github-tags depName=python/cpython | ||
PYTHON_VERSION: 3.12.3 | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 | ||
gv: | ||
name: Get value | ||
runs-on: ubuntu-latest | ||
outputs: | ||
value: ${{ steps.get-value.outputs.value }} | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- id: get-value | ||
name: Run this action | ||
uses: ./ | ||
- run: | | ||
echo "::notice ::Value: ${{ steps.get-value.outputs.value }}" | ||
show-value: | ||
name: Show value | ||
needs: gv | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: | | ||
echo "::notice ::Value: $VALUE" | ||
env: | ||
VALUE: ${{ fromJSON(needs.gv.outputs.value) }} | ||
release: | ||
name: Release | ||
needs: | ||
- pre-commit | ||
- show-value | ||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
- name: Run `semantic-release` | ||
uses: codfish/semantic-release-action@b0e57c976bf8f74b2454f59a30e4a1b5f11727b4 # v3.3.0 | ||
id: sem-rel | ||
with: | ||
plugins: | | ||
[ "@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/github" | ||
] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Update branch for major version | ||
if: steps.sem-rel.outputs.new-release-published == 'true' | ||
run: git push | ||
https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | ||
HEAD:refs/heads/v${{steps.sem-rel.outputs.release-major}} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
--- | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.6.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-merge-conflict | ||
args: [--assume-in-merge] | ||
- id: check-yaml | ||
- repo: https://github.com/python-jsonschema/check-jsonschema | ||
rev: 0.28.2 | ||
hooks: | ||
- id: check-github-workflows | ||
name: Check GitHub workflows with check-jsonschema | ||
args: ["--verbose"] | ||
- id: check-renovate | ||
name: Check Renovate config with check-jsonschema | ||
additional_dependencies: [json5==0.9.14] | ||
args: ["--verbose"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Example | ||
author: dafyddj | ||
description: An example composite action | ||
outputs: | ||
value: | ||
description: A basic output | ||
value: ${{ steps.get-value.outputs.value }} | ||
runs: | ||
using: composite | ||
steps: | ||
- id: get-value | ||
shell: bash | ||
run: | | ||
OUTPUT="value=true" | ||
echo "Setting '$OUTPUT'" | ||
echo "$OUTPUT" >> $GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY | ||
{{ _copier_answers|to_nice_yaml -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../base/action.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The following new files/directories were created: | ||
<Test Directory> | ||
----.copier-answers.yml | ||
----.github | ||
--------renovate.json5 | ||
--------workflows | ||
------------main.yml | ||
----.pre-commit-config.yaml | ||
----action.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../base/.github/workflows/main.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$TEXTTEST_ROOT/.. . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../base/.pre-commit-config.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/opt/homebrew/Cellar/copier/9.2.0/libexec/lib/python3.12/site-packages/copier/vcs.py:202: DirtyLocalWarning: Dirty template changes included automatically. | ||
warn( | ||
|
||
Copying from template version 0.0.0.post2.dev0+9966d43 | ||
[36m identical[39m[0m . | ||
[32m[1m create[39m[0m .copier-answers.yml | ||
[32m[1m create[39m[0m .github | ||
[32m[1m create[39m[0m .github/renovate.json5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Full path to the System Under Test (or Java Main Class name) | ||
executable:${TEXTTEST_ROOT}/../bin/copier | ||
|
||
# Naming scheme to use for files for stdin,stdout and stderr | ||
filename_convention_scheme:standard | ||
|
||
# Expanded name to use for application | ||
full_name:copier-github-action | ||
|
||
create_catalogues:true | ||
|
||
[collate_file] | ||
action_yml:action.yml | ||
main_yml:.github/workflows/main.yml | ||
pre-commit_yaml:.pre-commit-config.yaml | ||
|
||
[run_dependent_text] | ||
stderr:Copying from template version | ||
stderr:DirtyLocalWarning{LINES 2} | ||
stderr:No git tags found in template; using HEAD as ref | ||
stderr:create | ||
stderr:conflict | ||
stderr:identical | ||
stderr:overwrite | ||
stderr:skip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
copy --defaults --vcs-ref=HEAD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
GenerateProject |