From 066996d5bc2d472a0b0b839c2809486d41b1bdf3 Mon Sep 17 00:00:00 2001 From: galargh Date: Fri, 17 Dec 2021 11:47:55 +0100 Subject: [PATCH] move deploy_versioning to deploy_go action --- .github/actions/copy-workflow-go/action.yml | 12 ++++++++++++ .../copy-workflow-versioning/action.yml | 18 ------------------ .github/workflows/copy-workflow.yml | 3 --- configs/README.md | 2 +- configs/go.json | 11 +++++------ 5 files changed, 18 insertions(+), 28 deletions(-) delete mode 100644 .github/actions/copy-workflow-versioning/action.yml diff --git a/.github/actions/copy-workflow-go/action.yml b/.github/actions/copy-workflow-go/action.yml index cb27a595..71348c1a 100644 --- a/.github/actions/copy-workflow-go/action.yml +++ b/.github/actions/copy-workflow-go/action.yml @@ -62,3 +62,15 @@ runs: git add . git commit -m "run gofmt -s" fi + - name: add version.json file (in order to deploy versioning workflows) + if: hashFiles(format('{0}/version.json', env.TARGET_REPO_DIR)) == '' + working-directory: ${{ env.TARGET_REPO_DIR }} + shell: bash + run: | + git fetch origin --unshallow # we need the entire commit history + version=$(git describe --tags --abbrev=0 || true) # highest released version on current branch + if [[ -n "$version" ]]; then # only deply version.json if there's at least one release + printf '{"version": "%s"}' "$version" | jq . > version.json + git add version.json + git commit -m "add version.json file" + fi diff --git a/.github/actions/copy-workflow-versioning/action.yml b/.github/actions/copy-workflow-versioning/action.yml deleted file mode 100644 index 6acf1714..00000000 --- a/.github/actions/copy-workflow-versioning/action.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: copy workflow versioning -description: Copy workflow steps specific to versioning - -runs: - using: "composite" - steps: - - name: add version.json file (in order to deploy versioning workflows) - if: hashFiles(format('{0}/version.json', env.TARGET_REPO_DIR)) == '' - working-directory: ${{ env.TARGET_REPO_DIR }} - shell: bash - run: | - git fetch origin --unshallow # we need the entire commit history - version=$(git describe --tags --abbrev=0 || true) # highest released version on current branch - if [[ -n "$version" ]]; then # only deply version.json if there's at least one release - printf '{"version": "%s"}' "$version" | jq . > version.json - git add version.json - git commit -m "add version.json file" - fi diff --git a/.github/workflows/copy-workflow.yml b/.github/workflows/copy-workflow.yml index af0f407e..05f9ae7a 100644 --- a/.github/workflows/copy-workflow.yml +++ b/.github/workflows/copy-workflow.yml @@ -101,9 +101,6 @@ jobs: if: matrix.cfg.deploy_go # use of ${{ env.TEMPATE_REPO_DIR }} is not allowed here uses: ./template-repo/.github/actions/copy-workflow-go - - name: Run steps specific to versioning - if: matrix.cfg.deploy_versioning - uses: ./template-repo/.github/actions/copy-workflow-versioning - name: Add files run: | for f in $(jq -r '.[]' <<< ${{ toJson(env.FILES) }}); do diff --git a/configs/README.md b/configs/README.md index 9d51d514..d37299e9 100644 --- a/configs/README.md +++ b/configs/README.md @@ -32,7 +32,7 @@ When adding a new JSON config file, please follow the structure of other config } ``` -To customise the copy workflow further, you can add more fields to the `defaults` object. See `deploy_versioning` or `deploy_go` in [go.json](go.json) and how they are used in [copy-workflow.yml](../.github/workflows/copy-workflow.yml) for example. +To customise the copy workflow further, you can add more fields to the `defaults` object. See `deploy_go` in [go.json](go.json) and how it is used in [copy-workflow.yml](../.github/workflows/copy-workflow.yml) for example. ## Testing diff --git a/configs/go.json b/configs/go.json index c6dce5e3..a1b1bbed 100644 --- a/configs/go.json +++ b/configs/go.json @@ -1,14 +1,13 @@ { "defaults": { "files": [ - ".github/workflows/automerge.yml", - ".github/workflows/go-test.yml", - ".github/workflows/go-check.yml", - ".github/workflows/releaser.yml", - ".github/workflows/release-check.yml", + ".github/workflows/automerge.yml", + ".github/workflows/go-test.yml", + ".github/workflows/go-check.yml", + ".github/workflows/releaser.yml", + ".github/workflows/release-check.yml", ".github/workflows/tagpush.yml" ], - "deploy_versioning": true, "deploy_go": true }, "repositories": [