From c3f4bb815653fb5d81de2c2bbb4360c61668d61c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 09:33:34 +1100 Subject: [PATCH 01/21] Bump github.com/alecthomas/repr from 0.1.0 to 0.1.1 (#1379) Bumps [github.com/alecthomas/repr](https://github.com/alecthomas/repr) from 0.1.0 to 0.1.1. - [Release notes](https://github.com/alecthomas/repr/releases) - [Commits](https://github.com/alecthomas/repr/compare/v0.1.0...v0.1.1) --- updated-dependencies: - dependency-name: github.com/alecthomas/repr dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fcf07274..0b2659be 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/mikefarah/yq/v4 require ( github.com/a8m/envsubst v1.3.0 github.com/alecthomas/participle/v2 v2.0.0-beta.5 - github.com/alecthomas/repr v0.1.0 + github.com/alecthomas/repr v0.1.1 github.com/dimchansky/utfbom v1.1.1 github.com/elliotchance/orderedmap v1.5.0 github.com/fatih/color v1.13.0 diff --git a/go.sum b/go.sum index c2ec4a36..37b2e4d9 100644 --- a/go.sum +++ b/go.sum @@ -3,8 +3,8 @@ github.com/a8m/envsubst v1.3.0/go.mod h1:MVUTQNGQ3tsjOOtKCNd+fl8RzhsXcDvvAEzkhGt github.com/alecthomas/assert/v2 v2.0.3 h1:WKqJODfOiQG0nEJKFKzDIG3E29CN2/4zR9XGJzKIkbg= github.com/alecthomas/participle/v2 v2.0.0-beta.5 h1:y6dsSYVb1G5eK6mgmy+BgI3Mw35a3WghArZ/Hbebrjo= github.com/alecthomas/participle/v2 v2.0.0-beta.5/go.mod h1:RC764t6n4L8D8ITAJv0qdokritYSNR3wV5cVwmIEaMM= -github.com/alecthomas/repr v0.1.0 h1:ENn2e1+J3k09gyj2shc0dHr/yjaWSHRlrJ4DPMevDqE= -github.com/alecthomas/repr v0.1.0/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= +github.com/alecthomas/repr v0.1.1 h1:87P60cSmareLAxMc4Hro0r2RBY4ROm0dYwkJNpS4pPs= +github.com/alecthomas/repr v0.1.1/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From d16ee386d2dca9b24755037b6d774e542bb34a24 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Fri, 14 Oct 2022 14:24:57 +1100 Subject: [PATCH 02/21] Fixed broken link --- pkg/yqlib/doc/operators/datetime.md | 6 +++--- pkg/yqlib/doc/operators/headers/datetime.md | 4 ++-- pkg/yqlib/operator_datetime_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/yqlib/doc/operators/datetime.md b/pkg/yqlib/doc/operators/datetime.md index f97a37ea..36048e82 100644 --- a/pkg/yqlib/doc/operators/datetime.md +++ b/pkg/yqlib/doc/operators/datetime.md @@ -13,11 +13,11 @@ To specify a custom parsing format, use the `with_dtf` operator. The first param yq 'with_dtf("myformat"; .a + "3h" | tz("Australia/Melbourne"))' ``` -See https://pkg.go.dev/time#pkg-constants for examples of formatting options. +See the [library docs](https://pkg.go.dev/time#pkg-constants) for examples of formatting options. ## Timezones -This uses golangs built in LoadLocation function to parse timezones strings. See https://pkg.go.dev/time#LoadLocation for more details. +This uses golangs built in LoadLocation function to parse timezones strings. See the [library docs](https://pkg.go.dev/time#LoadLocation) for more details. ## Durations @@ -156,7 +156,7 @@ a: 2021-01-01T03:10:00Z ``` ## Date subtraction -You can subtract durations from dates. Assumes RFC3339 date time format, see [date-time operators](https://mikefarah.gitbook.io/yq/operators/date-time-operators) for more information. +You can subtract durations from dates. Assumes RFC3339 date time format, see [date-time operators](https://mikefarah.gitbook.io/yq/operators/datetime#date-time-formattings) for more information. Given a sample.yml file of: ```yaml diff --git a/pkg/yqlib/doc/operators/headers/datetime.md b/pkg/yqlib/doc/operators/headers/datetime.md index 39b0dd67..36da7178 100644 --- a/pkg/yqlib/doc/operators/headers/datetime.md +++ b/pkg/yqlib/doc/operators/headers/datetime.md @@ -13,11 +13,11 @@ To specify a custom parsing format, use the `with_dtf` operator. The first param yq 'with_dtf("myformat"; .a + "3h" | tz("Australia/Melbourne"))' ``` -See https://pkg.go.dev/time#pkg-constants for examples of formatting options. +See the [library docs](https://pkg.go.dev/time#pkg-constants) for examples of formatting options. ## Timezones -This uses golangs built in LoadLocation function to parse timezones strings. See https://pkg.go.dev/time#LoadLocation for more details. +This uses golangs built in LoadLocation function to parse timezones strings. See the [library docs](https://pkg.go.dev/time#LoadLocation) for more details. ## Durations diff --git a/pkg/yqlib/operator_datetime_test.go b/pkg/yqlib/operator_datetime_test.go index 094e08a3..2d01de49 100644 --- a/pkg/yqlib/operator_datetime_test.go +++ b/pkg/yqlib/operator_datetime_test.go @@ -77,7 +77,7 @@ var dateTimeOperatorScenarios = []expressionScenario{ }, { description: "Date subtraction", - subdescription: "You can subtract durations from dates. Assumes RFC3339 date time format, see [date-time operators](https://mikefarah.gitbook.io/yq/operators/date-time-operators) for more information.", + subdescription: "You can subtract durations from dates. Assumes RFC3339 date time format, see [date-time operators](https://mikefarah.gitbook.io/yq/operators/datetime#date-time-formattings) for more information.", document: `a: 2021-01-01T03:10:00Z`, expression: `.a -= "3h10m"`, expected: []string{ From 6db7acbf69c5cf15e367c2518099caf8b27ed8eb Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 17 Oct 2022 15:03:47 +1100 Subject: [PATCH 03/21] Added custom sort map example --- pkg/yqlib/doc/operators/entries.md | 20 ++++++++++++++++++++ pkg/yqlib/doc/operators/headers/sort-keys.md | 3 +++ pkg/yqlib/doc/operators/sort-keys.md | 3 +++ pkg/yqlib/operator_entries_test.go | 9 +++++++++ 4 files changed, 35 insertions(+) diff --git a/pkg/yqlib/doc/operators/entries.md b/pkg/yqlib/doc/operators/entries.md index b9d1ae9d..3c799b4c 100644 --- a/pkg/yqlib/doc/operators/entries.md +++ b/pkg/yqlib/doc/operators/entries.md @@ -107,6 +107,26 @@ KEY_a: 1 KEY_b: 2 ``` +## Custom sort map keys +Use to_entries to convert to an array of key/value pairs, sort the array using sort/sort_by/etc, and convert it back. + +Given a sample.yml file of: +```yaml +a: 1 +c: 3 +b: 2 +``` +then +```bash +yq 'to_entries | sort_by(.key) | reverse | from_entries' sample.yml +``` +will output +```yaml +c: 3 +b: 2 +a: 1 +``` + ## Use with_entries to filter the map Given a sample.yml file of: ```yaml diff --git a/pkg/yqlib/doc/operators/headers/sort-keys.md b/pkg/yqlib/doc/operators/headers/sort-keys.md index 0ef5cd23..31b0b6df 100644 --- a/pkg/yqlib/doc/operators/headers/sort-keys.md +++ b/pkg/yqlib/doc/operators/headers/sort-keys.md @@ -11,3 +11,6 @@ diff file1.yml file2.yml ``` Note that `yq` does not yet consider anchors when sorting by keys - this may result in invalid yaml documents if your are using merge anchors. + +For more advanced sorting, using `to_entries` to convert the map to an array, then sort/process the array as you like (e.g. using `sort_by`) and convert back to a map using `from_entries`. +See [here](https://mikefarah.gitbook.io/yq/operators/entries#custom-sort-map-keys) for an example. diff --git a/pkg/yqlib/doc/operators/sort-keys.md b/pkg/yqlib/doc/operators/sort-keys.md index b5101dc1..36c605d2 100644 --- a/pkg/yqlib/doc/operators/sort-keys.md +++ b/pkg/yqlib/doc/operators/sort-keys.md @@ -12,6 +12,9 @@ diff file1.yml file2.yml Note that `yq` does not yet consider anchors when sorting by keys - this may result in invalid yaml documents if your are using merge anchors. +For more advanced sorting, using `to_entries` to convert the map to an array, then sort/process the array as you like (e.g. using `sort_by`) and convert back to a map using `from_entries`. +See [here](https://mikefarah.gitbook.io/yq/operators/entries#custom-sort-map-keys) for an example. + {% hint style="warning" %} Note that versions prior to 4.18 require the 'eval/e' command to be specified. diff --git a/pkg/yqlib/operator_entries_test.go b/pkg/yqlib/operator_entries_test.go index 1419391d..9313323d 100644 --- a/pkg/yqlib/operator_entries_test.go +++ b/pkg/yqlib/operator_entries_test.go @@ -52,6 +52,15 @@ var entriesOperatorScenarios = []expressionScenario{ "D0, P[], (!!map)::KEY_a: 1\nKEY_b: 2\n", }, }, + { + description: "Custom sort map keys", + subdescription: "Use to_entries to convert to an array of key/value pairs, sort the array using sort/sort_by/etc, and convert it back.", + document: `{a: 1, c: 3, b: 2}`, + expression: `to_entries | sort_by(.key) | reverse | from_entries`, + expected: []string{ + "D0, P[], (!!map)::c: 3\nb: 2\na: 1\n", + }, + }, { skipDoc: true, document: `{a: 1, b: 2}`, From 9ca20451b71ce07cc0213748f36e7f22342cc1ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 15:15:19 +1100 Subject: [PATCH 04/21] Bump github.com/spf13/cobra from 1.5.0 to 1.6.0 (#1380) * Bump github.com/spf13/cobra from 1.5.0 to 1.6.0 Bumps [github.com/spf13/cobra](https://github.com/spf13/cobra) from 1.5.0 to 1.6.0. - [Release notes](https://github.com/spf13/cobra/releases) - [Commits](https://github.com/spf13/cobra/compare/v1.5.0...v1.6.0) --- updated-dependencies: - dependency-name: github.com/spf13/cobra dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Fixed deprecated usage of ExactArgs Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mike Farah --- cmd/shell-completion.go | 2 +- go.mod | 4 ++-- go.sum | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cmd/shell-completion.go b/cmd/shell-completion.go index 0fadfb12..5431abe0 100644 --- a/cmd/shell-completion.go +++ b/cmd/shell-completion.go @@ -42,7 +42,7 @@ $ yq shell-completion fish > ~/.config/fish/completions/yq.fish `, DisableFlagsInUseLine: true, ValidArgs: []string{"bash", "zsh", "fish", "powershell"}, - Args: cobra.ExactValidArgs(1), + Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), RunE: func(cmd *cobra.Command, args []string) error { var err error = nil switch args[0] { diff --git a/go.mod b/go.mod index 0b2659be..2d542605 100644 --- a/go.mod +++ b/go.mod @@ -12,14 +12,14 @@ require ( github.com/jinzhu/copier v0.3.5 github.com/magiconair/properties v1.8.6 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e - github.com/spf13/cobra v1.5.0 + github.com/spf13/cobra v1.6.0 golang.org/x/net v0.0.0-20220708220712-1185a9018129 gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/mattn/go-colorable v0.1.12 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/spf13/pflag v1.0.5 // indirect diff --git a/go.sum b/go.sum index 37b2e4d9..22f0dc50 100644 --- a/go.sum +++ b/go.sum @@ -24,8 +24,8 @@ github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG github.com/goccy/go-yaml v1.9.5 h1:Eh/+3uk9kLxG4koCX6lRMAPS1OaMSAi+FJcya0INdB0= github.com/goccy/go-yaml v1.9.5/go.mod h1:U/jl18uSupI5rdI2jmuCswEA2htH9eXfferR3KfscvA= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= -github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc= +github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg= github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= @@ -43,8 +43,8 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= -github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= +github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI= +github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -77,7 +77,6 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473 h1:6D+BvnJ/j6e222UW8s2qTSe3wGBtvo0MbVQG/c5k8RE= gopkg.in/op/go-logging.v1 v1.0.0-20160211212156-b2cb9fa56473/go.mod h1:N1eN2tsCx0Ydtgjl4cqmbRCsY4/+z4cYDeqwZTk6zog= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 780ae29c2be35fe2512a8657cc2f3db871f2c8ba Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 17 Oct 2022 15:27:24 +1100 Subject: [PATCH 05/21] Improved github action test --- .github/workflows/test-yq.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-yq.yml b/.github/workflows/test-yq.yml index 7c019700..b292cc3a 100644 --- a/.github/workflows/test-yq.yml +++ b/.github/workflows/test-yq.yml @@ -12,11 +12,14 @@ jobs: steps: - uses: actions/checkout@v3 - name: Get test + id: get_value uses: mikefarah/yq@master with: - cmd: yq eval '.a' examples/sample.yaml + cmd: yq '.b.e[0].name' examples/sample.yaml + - name: Who stole the cookie + run: echo "### It was [${{ steps.get_value.outputs.result }}]" >> $GITHUB_STEP_SUMMARY - name: Write inplace test id: lookupSdkVersion uses: mikefarah/yq@master with: - cmd: yq eval -i '.b.c = 5' examples/sample.yaml \ No newline at end of file + cmd: yq -i '.b.c = 5' examples/sample.yaml \ No newline at end of file From dee0c94346ee3810e741b663c7b043dc3aa66af4 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 17 Oct 2022 15:33:12 +1100 Subject: [PATCH 06/21] Updating action to new entrypoint format --- github-action/entrypoint.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/github-action/entrypoint.sh b/github-action/entrypoint.sh index 8ce2a3ad..ec22c359 100755 --- a/github-action/entrypoint.sh +++ b/github-action/entrypoint.sh @@ -6,4 +6,6 @@ RESULT="${RESULT//'%'/'%25'}" RESULT="${RESULT//$'\n'/'%0A'}" RESULT="${RESULT//$'\r'/'%0D'}" echo "::debug::\$RESULT: $RESULT" -echo ::set-output name=result::"$RESULT" +# updating from +# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter +echo "RESULT=$RESULT" >> $GITHUB_OUTPUT \ No newline at end of file From 28a6c9c532f3eedb00d0ba103ad3c4c69e6e09cc Mon Sep 17 00:00:00 2001 From: mattphelps-8451 Date: Mon, 17 Oct 2022 21:41:58 -0500 Subject: [PATCH 07/21] Fix set-output deprecate; keys are case sensitive (#1383) --- github-action/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github-action/entrypoint.sh b/github-action/entrypoint.sh index ec22c359..17ec5411 100755 --- a/github-action/entrypoint.sh +++ b/github-action/entrypoint.sh @@ -8,4 +8,4 @@ RESULT="${RESULT//$'\r'/'%0D'}" echo "::debug::\$RESULT: $RESULT" # updating from # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter -echo "RESULT=$RESULT" >> $GITHUB_OUTPUT \ No newline at end of file +echo "result=$RESULT" >> $GITHUB_OUTPUT From 8a45e02cbb8e5486b8b948fbe4ad4df1e0f7aae9 Mon Sep 17 00:00:00 2001 From: mattphelps-8451 Date: Tue, 18 Oct 2022 18:16:07 -0500 Subject: [PATCH 08/21] Fix broken multiline strings from dee0c94 (#1390) 1. Escaping behavior changed as a result of set-output deprecation. - Otherwise you'll encounter breaking changes for example "appVersion: "1.0.0"%0Aapplica..." where %0A is escaped newline \n but shouldn't be escaped. 2. Delimeter is required for multiline strings. - See here: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings - Delimeter must be random. UUID is a solid choice. I verified that /proc/sys/kernel/random/uuid does indeed exist on the yq image. --- github-action/entrypoint.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/github-action/entrypoint.sh b/github-action/entrypoint.sh index 17ec5411..a328fbd2 100755 --- a/github-action/entrypoint.sh +++ b/github-action/entrypoint.sh @@ -2,10 +2,11 @@ set -e echo "::debug::\$cmd: $1" RESULT=$(eval "$1") -RESULT="${RESULT//'%'/'%25'}" -RESULT="${RESULT//$'\n'/'%0A'}" -RESULT="${RESULT//$'\r'/'%0D'}" echo "::debug::\$RESULT: $RESULT" # updating from +# https://github.com/orgs/community/discussions/26288#discussioncomment-3876281 # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter -echo "result=$RESULT" >> $GITHUB_OUTPUT +delimiter=$(cat /proc/sys/kernel/random/uuid) +echo "result<<${delimiter}" >> "${GITHUB_OUTPUT}" +echo "${RESULT}" >> "${GITHUB_OUTPUT}" +echo "${delimiter}" >> "${GITHUB_OUTPUT}" From ecc490a0fa3312b2d3c412a70aa896b88dba689e Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 10:48:05 +1100 Subject: [PATCH 09/21] Attempt to prebuild github action --- .../docker-release-github-action.yml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/docker-release-github-action.yml diff --git a/.github/workflows/docker-release-github-action.yml b/.github/workflows/docker-release-github-action.yml new file mode 100644 index 00000000..bba59f9e --- /dev/null +++ b/.github/workflows/docker-release-github-action.yml @@ -0,0 +1,63 @@ +name: Release Docker + +on: + release: + types: [released] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + publishDocker: + environment: dockerhub + env: + IMAGE_NAME: mikefarah/yq + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + with: + platforms: all + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v2 + with: + version: latest + + - name: Available platforms + run: echo ${{ steps.buildx.outputs.platforms }} && docker version + + - name: Build and push image + run: | + echo "GithubRef: ${GITHUB_REF}" + VERSION=${GITHUB_REF##*/} + echo "VERSION: ${VERSION}" + IMAGE_VERSION=${VERSION:1} + echo "IMAGE_VERSION: ${IMAGE_VERSION}" + + PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64" + + echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}" + echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin + cd github-action + docker buildx build \ + --label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \ + --label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \ + --label "org.opencontainers.image.description=yq is a portable command-line YAML processor" \ + --label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \ + --label "org.opencontainers.image.licenses=MIT" \ + --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ + --label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \ + --label "org.opencontainers.image.title=yq" \ + --label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \ + --label "org.opencontainers.image.version=${IMAGE_VERSION}" \ + --platform "${PLATFORMS}" \ + --pull \ + --push \ + -t "${IMAGE_NAME}:${IMAGE_VERSION}-githubaction" \ + -t "${IMAGE_NAME}:4-githubaction" \ + -t "${IMAGE_NAME}:latest-githubaction" \ + . From cb4c41eebfbd6a41cff6ef9ec595cbda84d0074a Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 10:49:04 +1100 Subject: [PATCH 10/21] different name to docker github action --- .github/workflows/docker-release-github-action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-release-github-action.yml b/.github/workflows/docker-release-github-action.yml index bba59f9e..4c346e9b 100644 --- a/.github/workflows/docker-release-github-action.yml +++ b/.github/workflows/docker-release-github-action.yml @@ -1,4 +1,4 @@ -name: Release Docker +name: Release Github action Docker on: release: From 8ed817916f64621604672d89b2ff1b752dc69ef6 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 10:59:09 +1100 Subject: [PATCH 11/21] muiltiline github action test --- .github/workflows/test-yq.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-yq.yml b/.github/workflows/test-yq.yml index b292cc3a..4047127d 100644 --- a/.github/workflows/test-yq.yml +++ b/.github/workflows/test-yq.yml @@ -15,8 +15,8 @@ jobs: id: get_value uses: mikefarah/yq@master with: - cmd: yq '.b.e[0].name' examples/sample.yaml - - name: Who stole the cookie + cmd: yq '.test' examples/multiline-text.yaml + - name: Multiline test run: echo "### It was [${{ steps.get_value.outputs.result }}]" >> $GITHUB_STEP_SUMMARY - name: Write inplace test id: lookupSdkVersion From 22c44d3ecb59643a9be7270307e404b46a85d2e2 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 11:04:53 +1100 Subject: [PATCH 12/21] action uses built docker image --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e6beb159..2cc99d5f 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,6 @@ outputs: description: "The complete result from the yq command being run" runs: using: 'docker' - image: 'github-action/Dockerfile' + image: 'docker.io/mikefarah/yq:4-githubaction' args: - ${{ inputs.cmd }} From a264833c06ab48607c6f2c7ecfadf1b6d96129ac Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 11:05:09 +1100 Subject: [PATCH 13/21] test action using built docker image --- .github/workflows/test-yq.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-yq.yml b/.github/workflows/test-yq.yml index 4047127d..5e28adb8 100644 --- a/.github/workflows/test-yq.yml +++ b/.github/workflows/test-yq.yml @@ -13,13 +13,13 @@ jobs: - uses: actions/checkout@v3 - name: Get test id: get_value - uses: mikefarah/yq@master + uses: mikefarah/yq@action-use-published-docker with: cmd: yq '.test' examples/multiline-text.yaml - name: Multiline test run: echo "### It was [${{ steps.get_value.outputs.result }}]" >> $GITHUB_STEP_SUMMARY - name: Write inplace test id: lookupSdkVersion - uses: mikefarah/yq@master + uses: mikefarah/yq@action-use-published-docker with: cmd: yq -i '.b.c = 5' examples/sample.yaml \ No newline at end of file From 0b235b367d1b9e29a943cacee874ee7bb045c244 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 11:06:41 +1100 Subject: [PATCH 14/21] action uses built docker image --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 2cc99d5f..3ff32f57 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,6 @@ outputs: description: "The complete result from the yq command being run" runs: using: 'docker' - image: 'docker.io/mikefarah/yq:4-githubaction' + image: 'docker://mikefarah/yq:4-githubaction' args: - ${{ inputs.cmd }} From 600e132fb6cf9ec6819ca968b66dfe41fd516980 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 11:10:50 +1100 Subject: [PATCH 15/21] Actions use built docker-images --- .../docker-release-github-action.yml | 63 ------------------- .github/workflows/docker-release.yml | 20 ++++++ 2 files changed, 20 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/docker-release-github-action.yml diff --git a/.github/workflows/docker-release-github-action.yml b/.github/workflows/docker-release-github-action.yml deleted file mode 100644 index 4c346e9b..00000000 --- a/.github/workflows/docker-release-github-action.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Release Github action Docker - -on: - release: - types: [released] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -jobs: - publishDocker: - environment: dockerhub - env: - IMAGE_NAME: mikefarah/yq - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - with: - platforms: all - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - with: - version: latest - - - name: Available platforms - run: echo ${{ steps.buildx.outputs.platforms }} && docker version - - - name: Build and push image - run: | - echo "GithubRef: ${GITHUB_REF}" - VERSION=${GITHUB_REF##*/} - echo "VERSION: ${VERSION}" - IMAGE_VERSION=${VERSION:1} - echo "IMAGE_VERSION: ${IMAGE_VERSION}" - - PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64" - - echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}" - echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin - cd github-action - docker buildx build \ - --label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \ - --label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \ - --label "org.opencontainers.image.description=yq is a portable command-line YAML processor" \ - --label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \ - --label "org.opencontainers.image.licenses=MIT" \ - --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ - --label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \ - --label "org.opencontainers.image.title=yq" \ - --label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \ - --label "org.opencontainers.image.version=${IMAGE_VERSION}" \ - --platform "${PLATFORMS}" \ - --pull \ - --push \ - -t "${IMAGE_NAME}:${IMAGE_VERSION}-githubaction" \ - -t "${IMAGE_NAME}:4-githubaction" \ - -t "${IMAGE_NAME}:latest-githubaction" \ - . diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 56796236..17890b27 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -60,3 +60,23 @@ jobs: -t "${IMAGE_NAME}:4" \ -t "${IMAGE_NAME}:latest" \ . + + cd github-action + docker buildx build \ + --label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \ + --label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \ + --label "org.opencontainers.image.description=yq is a portable command-line YAML processor" \ + --label "org.opencontainers.image.documentation=https://mikefarah.gitbook.io/yq/" \ + --label "org.opencontainers.image.licenses=MIT" \ + --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ + --label "org.opencontainers.image.source=https://github.com/mikefarah/yq" \ + --label "org.opencontainers.image.title=yq" \ + --label "org.opencontainers.image.url=https://mikefarah.gitbook.io/yq/" \ + --label "org.opencontainers.image.version=${IMAGE_VERSION}" \ + --platform "${PLATFORMS}" \ + --pull \ + --push \ + -t "${IMAGE_NAME}:${IMAGE_VERSION}-githubaction" \ + -t "${IMAGE_NAME}:4-githubaction" \ + -t "${IMAGE_NAME}:latest-githubaction" \ + . From 1f0881fb5faf371694bfa108753cda0b824f5037 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 11:14:32 +1100 Subject: [PATCH 16/21] Bumping version --- cmd/version.go | 2 +- release_notes.txt | 7 +++++++ snap/snapcraft.yaml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/version.go b/cmd/version.go index 1aecbc91..f973ad06 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -11,7 +11,7 @@ var ( GitDescribe string // Version is main version number that is being run at the moment. - Version = "4.28.1" + Version = "4.28.2" // VersionPrerelease is a pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release diff --git a/release_notes.txt b/release_notes.txt index 41eb74a0..875aa743 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -1,3 +1,10 @@ +4.28.2: + - Fixed bug - can now delete documents #1377 + - Fixed handling of UTF8 encoded CSVs #1373 + - Detect and fail on missing closing brackets #1366 + - yq Github actions now build docker image as part of release + - Bumped dependencies + 4.28.1: - Added `setpath` and `delpaths` operators, like jq (#1374) - Added `is_key` operator, to check if a match was a key when recursing diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 1e8f6683..0e7bbdae 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -1,5 +1,5 @@ name: yq -version: '4.28.1' +version: '4.28.2' summary: A lightweight and portable command-line YAML processor description: | The aim of the project is to be the jq or sed of yaml files. From 5ef9101913a611d2b8d8998c93eb55705ab2da72 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 11:25:56 +1100 Subject: [PATCH 17/21] Updated release notes --- release_notes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/release_notes.txt b/release_notes.txt index 875aa743..1b1178cc 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -1,4 +1,5 @@ 4.28.2: + - Fixed Github Actions issues (thanks @mattphelps-845) - Fixed bug - can now delete documents #1377 - Fixed handling of UTF8 encoded CSVs #1373 - Detect and fail on missing closing brackets #1366 From 6c94869329ee8b3a372defee3c9e006507f2e399 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 19 Oct 2022 12:04:52 +1100 Subject: [PATCH 18/21] test yq action can now be run manually --- .github/workflows/test-yq.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-yq.yml b/.github/workflows/test-yq.yml index 5e28adb8..ef34d144 100644 --- a/.github/workflows/test-yq.yml +++ b/.github/workflows/test-yq.yml @@ -1,5 +1,8 @@ name: Test Yq Action -on: [push] +on: + push: + workflow_dispatch: + permissions: contents: read @@ -13,13 +16,13 @@ jobs: - uses: actions/checkout@v3 - name: Get test id: get_value - uses: mikefarah/yq@action-use-published-docker + uses: mikefarah/yq@master with: cmd: yq '.test' examples/multiline-text.yaml - name: Multiline test run: echo "### It was [${{ steps.get_value.outputs.result }}]" >> $GITHUB_STEP_SUMMARY - name: Write inplace test id: lookupSdkVersion - uses: mikefarah/yq@action-use-published-docker + uses: mikefarah/yq@master with: cmd: yq -i '.b.c = 5' examples/sample.yaml \ No newline at end of file From ea4a50f6e9299d06578fd27447470da35485d9d8 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Thu, 20 Oct 2022 09:59:36 +1100 Subject: [PATCH 19/21] Fixing matt phelps username reference --- release_notes.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_notes.txt b/release_notes.txt index 1b1178cc..c234f8b3 100644 --- a/release_notes.txt +++ b/release_notes.txt @@ -1,5 +1,5 @@ 4.28.2: - - Fixed Github Actions issues (thanks @mattphelps-845) + - Fixed Github Actions issues (thanks @mattphelps-8451) - Fixed bug - can now delete documents #1377 - Fixed handling of UTF8 encoded CSVs #1373 - Detect and fail on missing closing brackets #1366 From eac988abdc3a0a31f6101fefe5be3c7c15429b57 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Sun, 23 Oct 2022 14:50:00 +1100 Subject: [PATCH 20/21] Updated release to always use latest go --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 86296c16..4a07f8cd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,7 @@ jobs: - uses: actions/setup-go@v3 with: go-version: '^1.19' + check-latest: true - name: Compile man page markup id: gen-man-page-md run: | From 14f827b9b7c1e5dccdc86d014783dc4009c2fa3f Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Mon, 24 Oct 2022 09:42:22 +1100 Subject: [PATCH 21/21] Added nix installation instructions --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d48743b..2df32967 100644 --- a/README.md +++ b/README.md @@ -242,7 +242,17 @@ go install github.com/mikefarah/yq/v4@latest ## Community Supported Installation methods As these are supported by the community :heart: - however, they may be out of date with the officially supported releases. -# Webi + +### Nix + +``` +nix profile install nixpkgs#yq-go +``` + +See [here](https://search.nixos.org/packages?channel=unstable&show=yq-go&from=0&size=50&sort=relevance&type=packages&query=yq-go) + + +### Webi ``` webi yq