From e4784bb16b5f100aa4f744c75affcc990d026677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20BIDON?= Date: Sat, 29 Nov 2025 09:16:19 +0100 Subject: [PATCH] ci: added svu tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * updated README * new tool svu * now badge uses github releases * go.mod badge was messy and unresponsive. Added webhook on repo to notify release events to fury.io * updated go-ctrf-json-reporter * updated released binary * now ships binaries with releases. No longer need go install * added svu installer action * added dependency to go.mod Signed-off-by: Frédéric BIDON --- .github/workflows/release.yml | 12 ++- .github/workflows/test.yml | 18 ++-- README.md | 20 ++++- action.yml | 39 ++++++++- get-tool-version.sh | 3 + go.mod | 21 +++-- go.sum | 38 +++++++-- install/go-ctrf-json-reporter/action.yml | 50 +++++++++-- install/go-junit-report/action.yml | 8 +- install/gotestsum/action.yml | 18 +++- install/svu/action.yml | 103 +++++++++++++++++++++++ release_tracker.go | 1 + 12 files changed, 285 insertions(+), 46 deletions(-) create mode 100644 install/svu/action.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec13715..2f52b3f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,10 +27,10 @@ jobs: fetch-depth: 0 - name: Extract tag message - id: get_message - # git-cliff may or may not pick the current tag message, difficult to tell when - # this works. We extract the tag message explicitly. + id: get-message + # tag message is not retrieved unless with fetch the ref explictly run: | + git fetch --depth=1 origin +refs/tags/*:refs/tags/* MESSAGE=$(git tag -l '${{ github.ref_name }}' --format='%(contents:subject) %(contents:body) @@ -41,6 +41,9 @@ jobs: printenv MESSAGE echo 'EOF' } >> "${GITHUB_OUTPUT}" + + echo "Message in git tag ${{ github.ref_name }}" + echo "$MESSAGE" - name: Generate release notes id: notes @@ -52,9 +55,10 @@ jobs: config: '.cliff.toml' args: >- --current - --with-tag-message '${{ steps.get_message.outputs.message }}' + --with-tag-message '${{ steps.get-message.outputs.message }}' - name: Create github release uses: softprops/action-gh-release@5be0e66d93ac7ed76da52eca8bb058f665c3a5fe # v2.4.2 with: body: ${{ steps.notes.outputs.content }} + generate_release_notes: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2412fee..669f9bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,6 +7,10 @@ on: pull_request: workflow_dispatch: +defaults: + run: + shell: bash + jobs: lint-action: name: Lint actions @@ -43,21 +47,18 @@ jobs: test-action: name: Test install actions - runs-on: ubuntu-latest permissions: contents: read + runs-on: ${{ matrix.os }} + needs: [lint-action] + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-latest ] steps: - name: Checkout repository uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - - uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0 - # At this moment, one of the installed tools is not released as a binary and requires a go-setup - with: - go-version: stable - check-latest: true - cache: true - - name: Run install-all action id: test-action uses: ./ @@ -68,3 +69,4 @@ jobs: gotestsum --help go-junit-report --help go-ctrf-json-reporter --help + svu --help diff --git a/README.md b/README.md index a24ba95..229232c 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ GitHub Actions used by go-openapi workflows. ## Status -This project is still in a very early stage. It is being actively developed and has not released yet. +These actions are currently used by the CI workflows run at `github.com/go-openapi`. ## Usage @@ -36,9 +36,19 @@ To use this action in your workflow, reference it using the standard GitHub Acti - uses: go-openapi/gh-actions/install/go-ctrf-json-reporter@v1 ``` +## Installed tools + +All tools are currently installed using downloaded released binaries. + +* [gotestsum](https://github.com/gotestyourself/gotestsum/) +* [go-junit-report](https://github.com/jstemmer/go-junit-report) +* [go-ctrf-json-reporter](https://github.com/ctrf-io/go-ctrf-json-reporter) +* [svu](https://github.com/caarlos0/svu) + ## Motivation -This repository currently exposes "installer" actions for some testing go tools and +This repository currently exposes "installer" actions for some testing go tools. + CI workflows may use and pin released actions instead of resorting to a `go install ...@latest` command. @@ -78,8 +88,10 @@ This library ships under the [SPDX-License-Identifier: Apache-2.0](./LICENSE). [codeql-badge]: https://github.com/go-openapi/gh-actions/actions/workflows/codeql.yml/badge.svg [codeql-url]: https://github.com/go-openapi/gh-actions/actions/workflows/codeql.yml -[release-badge]: https://badge.fury.io/go/github.com%2Fgo-openapi%2Fgh-actions.svg -[release-url]: https://badge.fury.io/go/github.com%2Fgo-openapi%2Fgh-actions +[release-badge]: https://badge.fury.io/gh/go-openapi%2Fgh-actions.svg +[release-url]: https://badge.fury.io/gh/go-openapi%2Fgh-actions +[gomod-badge]: https://badge.fury.io/go/github.com%2Fgo-openapi%2Fgh-actions.svg +[gomod-url]: https://badge.fury.io/go/github.com%2Fgo-openapi%2Fgh-actions [gocard-badge]: https://goreportcard.com/badge/github.com/go-openapi/gh-actions [gocard-url]: https://goreportcard.com/report/github.com/go-openapi/gh-actions diff --git a/action.yml b/action.yml index d7f3ca2..c37659e 100644 --- a/action.yml +++ b/action.yml @@ -2,45 +2,82 @@ name: go-openapi composite action description: | Composite github action for go-openapi workflows. - It installs the following test tools from binary releases: + Installs the following test tools from binary releases: * gotestsum * go-junit-report * go-ctrf-json-reporter + * svu Please refer to [the documentation](./README.md). author: go-openapi inputs: + install-gotestsum: + default: 'true' + required: false version-gotestsum: default: auto required: false + description: | + The version to install specifically. + Defaults to 'auto': the version currenty released (see go.mod). + install-go-junit-report: + default: 'true' + required: false version-go-junit-report: default: auto required: false + description: | + The version to install specifically. + Defaults to 'auto': the version currenty released (see go.mod). + install-go-ctrf-json-reporter: + default: 'true' + required: false version-go-ctrf-json-reporter: default: auto required: false + description: | + The version to install specifically. + Defaults to 'auto': the version currenty released (see go.mod). + install-svu: + default: 'true' + required: false + version-svu: + default: auto + required: false + description: | + The version to install specifically. + Defaults to 'auto': the version currenty released (see go.mod). runs: using: composite steps: - + if: ${{ inputs.install-gotestsum == 'true' }} name: Install gotestsum uses: ./install/gotestsum with: version: ${{ inputs.version-gotestsum }} - + if: ${{ inputs.install-go-junit-report == 'true' }} name: Install go-junit-report uses: ./install/go-junit-report with: version: ${{ inputs.version-go-junit-report }} - + if: ${{ inputs.install-go-ctrf-json-reporter == 'true' }} name: Install go-ctrf-json-reporter uses: ./install/go-ctrf-json-reporter with: version: ${{ inputs.version-go-ctrf-json-reporter }} + - + if: ${{ inputs.install-svu == 'true' }} + name: Install svu + uses: ./install/svu + with: + version: ${{ inputs.version-go-ctrf-json-reporter }} branding: icon: 'package' diff --git a/get-tool-version.sh b/get-tool-version.sh index 60486a1..3c1c594 100755 --- a/get-tool-version.sh +++ b/get-tool-version.sh @@ -17,6 +17,9 @@ case "${tool}" in gotestsum) GO_IMPORT_PATH="gotest.tools/gotestsum" ;; + svu) + GO_IMPORT_PATH="github.com/caarlos0/svu" + ;; *) echo "Unrecognized tool name" exit 1 diff --git a/go.mod b/go.mod index 7e39d39..e224695 100644 --- a/go.mod +++ b/go.mod @@ -1,26 +1,29 @@ module gh-actions -go 1.24.0 +go 1.25.3 require ( - github.com/ctrf-io/go-ctrf-json-reporter v0.0.14 + github.com/caarlos0/svu/v3 v3.3.0 + github.com/ctrf-io/go-ctrf-json-reporter v0.0.15 github.com/jstemmer/go-junit-report/v2 v2.1.0 gotest.tools/gotestsum v1.13.0 ) require ( + github.com/Masterminds/semver/v3 v3.4.0 // indirect github.com/bitfield/gotestdox v0.2.2 // indirect github.com/dnephin/pflag v1.0.7 // indirect github.com/fatih/color v1.18.0 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/gobwas/glob v0.2.3 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - golang.org/x/mod v0.27.0 // indirect - golang.org/x/sync v0.17.0 // indirect - golang.org/x/sys v0.36.0 // indirect - golang.org/x/term v0.35.0 // indirect - golang.org/x/text v0.17.0 // indirect - golang.org/x/tools v0.36.0 // indirect + golang.org/x/mod v0.30.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/term v0.37.0 // indirect + golang.org/x/text v0.31.0 // indirect + golang.org/x/tools v0.39.0 // indirect ) diff --git a/go.sum b/go.sum index 0854d19..1470b6f 100644 --- a/go.sum +++ b/go.sum @@ -1,15 +1,27 @@ +github.com/Masterminds/semver/v3 v3.3.1 h1:QtNSWtVZ3nBfk8mAOu/B6v7FMJ+NHTIgUPi7rj+4nv4= +github.com/Masterminds/semver/v3 v3.3.1/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0= +github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE= github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY= +github.com/caarlos0/svu/v3 v3.0.0 h1:nuKoqZKG1jHEq/RyKpsLKCcUHI2Uw/ZwBOfhq+x36AU= +github.com/caarlos0/svu/v3 v3.0.0/go.mod h1:aqzsE84JVirxxkIS1tzfilxmuHkkXu3FUfdGkbTlORE= +github.com/caarlos0/svu/v3 v3.3.0 h1:zjG8BQd5tWlr5kjqh5uJBnBEoNp0GfvFxGBIHgUcrjc= +github.com/caarlos0/svu/v3 v3.3.0/go.mod h1:WtAu3yAuNo4zOkvHxp4bk/RgFc8OCt+Tr/A7OtOK51M= github.com/ctrf-io/go-ctrf-json-reporter v0.0.14 h1:/Yyx+wedA4i62+M1r+/LLNIJ0XK8GV/y7CUTVq/JMcg= github.com/ctrf-io/go-ctrf-json-reporter v0.0.14/go.mod h1:36bVomyu0b70mpxgIQVllRXYyQFPSS+CeHZTn7zxYzQ= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/ctrf-io/go-ctrf-json-reporter v0.0.15 h1:dnlUISSw50Mwz1ZME4kqF4rNF+JWFqs0kQ+oaJGJShw= +github.com/ctrf-io/go-ctrf-json-reporter v0.0.15/go.mod h1:36bVomyu0b70mpxgIQVllRXYyQFPSS+CeHZTn7zxYzQ= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= @@ -21,29 +33,43 @@ github.com/jstemmer/go-junit-report/v2 v2.1.0 h1:X3+hPYlSczH9IMIpSC9CQSZA0L+BipY github.com/jstemmer/go-junit-report/v2 v2.1.0/go.mod h1:mgHVr7VUo5Tn8OLVr1cKnLuEy0M92wdRntM99h7RkgQ= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -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/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/mod v0.27.0 h1:kb+q2PyFnEADO2IEF935ehFUXlWiNjJWtRNgBLSfbxQ= golang.org/x/mod v0.27.0/go.mod h1:rWI627Fq0DEoudcK+MBkNkCe0EetEaDSwJJkCcjpazc= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k= golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ= golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA= +golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= +golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg= golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/gotestsum v1.13.0 h1:+Lh454O9mu9AMG1APV4o0y7oDYKyik/3kBOiCqiEpRo= diff --git a/install/go-ctrf-json-reporter/action.yml b/install/go-ctrf-json-reporter/action.yml index f9bd415..477cbe7 100644 --- a/install/go-ctrf-json-reporter/action.yml +++ b/install/go-ctrf-json-reporter/action.yml @@ -4,9 +4,6 @@ description: | github.com/ctrf-io/go-ctrf-json-reporter@{version} - NOTE: go-ctrf-json-report doesn't currently issue binary releases: - so this is a go build that requires a go install. - author: go-openapi inputs: @@ -26,6 +23,20 @@ outputs: runs: using: composite steps: + - + name: Check if runner is supported + if: >- + ${{ + (runner.os != 'Linux' && runner.os != 'macOS' && runner.os != 'Windows') || + (runner.os == 'Linux' && runner.arch != 'X64' ) || + (runner.os == 'Windows' && runner.arch != 'X64' ) || + (runner.os == 'macOS' && runner.arch != 'ARM64') + }} + shell: bash + run: | + echo "::error::installation not supported for ${{ runner.os }} on ${{ runner.arch }}" + echo "::error::please build locally with go or see available artifacts at https://github.com/gotestyourself/gotestsum/releases" + exit 1 - name: Resolve version id: resolve-version @@ -54,11 +65,36 @@ runs: REPO: github.com/ctrf-io/go-ctrf-json-reporter TOOL: go-ctrf-json-reporter VERSION: ${{ steps.resolve-version.outputs.version }} + DOWNLOAD_DIR: ${{ runner.temp }}/downloads + TARGET_DIR: ${{ github.action_path }}/bin + GH_TOKEN: ${{ github.token }} run: | - set -x - go install "${REPO}"/cmd/"${TOOL}"@"${VERSION}" - TARGET_DIR=${GOPATH:-${HOME}/go}/bin - echo "${TARGET_DIR}/bin" >> "$GITHUB_PATH" + OS=$(echo '${{ runner.os }}'|sed 's/macOS/Darwin/') + ARCH=$(echo '${{ runner.arch }}'|tr '[A-Z]' '[a-z]'|sed 's/x64/x86_64/') + + mkdir -p "${DOWNLOAD_DIR}" + + ARCHIVE_FORMAT=".tar.gz" + if [[ "${OS}" == "Windows" ]] ; then + ARCHIVE_FORMAT=".zip" + fi + + gh release download "${VERSION}" \ + --repo "${REPO}" \ + --pattern "*_${OS}_${ARCH}${ARCHIVE_FORMAT}" \ + --output "${DOWNLOAD_DIR}"/"artifact${ARCHIVE_FORMAT}" + + if [[ "${OS}" != "Windows" ]] ; then + (cd "${DOWNLOAD_DIR}" && tar xf "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") + else + TOOL="${TOOL}.exe" + (cd "${DOWNLOAD_DIR}" && unzip "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") + fi + + mkdir -p "${TARGET_DIR}" + mv "${DOWNLOAD_DIR}"/"${TOOL}" "${TARGET_DIR}" + + echo '${{ github.action_path }}/bin' >> "$GITHUB_PATH" branding: icon: 'package' diff --git a/install/go-junit-report/action.yml b/install/go-junit-report/action.yml index 6d1f110..1b2ec27 100644 --- a/install/go-junit-report/action.yml +++ b/install/go-junit-report/action.yml @@ -28,7 +28,9 @@ runs: if: >- ${{ (runner.os != 'Linux' && runner.os != 'macOS' && runner.os != 'Windows') || - (runner.arch != 'X64' ) + (runner.os == 'Linux' && runner.arch != 'X64' ) || + (runner.os == 'Windows' && runner.arch != 'X64' ) || + (runner.os == 'macOS' && runner.arch != 'ARM64') }} shell: bash run: | @@ -73,7 +75,6 @@ runs: mkdir -p "${DOWNLOAD_DIR}" set -x - # e.g. go-junit-report-v2.1.0-darwin-arm64.tar.gz ARCHIVE_FORMAT=".tar.gz" if [[ '${{ runner.os }}' == 'Windows' ]] ; then ARCHIVE_FORMAT=".zip" @@ -84,8 +85,7 @@ runs: --pattern "*-${OS}-${ARCH}${ARCHIVE_FORMAT}" \ --output "${DOWNLOAD_DIR}"/"artifact${ARCHIVE_FORMAT}" - # should check checksum etc - if [[ "${OS}" != 'windows' ]] ; then + if [[ "${OS}" != "windows" ]] ; then (cd "${DOWNLOAD_DIR}" && tar xf "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") else TOOL="${TOOL}.exe" diff --git a/install/gotestsum/action.yml b/install/gotestsum/action.yml index 2ad53b3..7b7f306 100644 --- a/install/gotestsum/action.yml +++ b/install/gotestsum/action.yml @@ -23,6 +23,20 @@ outputs: runs: using: composite steps: + - + name: Check if runner is supported + if: >- + ${{ + (runner.os != 'Linux' && runner.os != 'macOS' && runner.os != 'Windows') || + (runner.os == 'Linux' && runner.arch != 'X64' ) || + (runner.os == 'Windows' && runner.arch != 'X64' ) || + (runner.os == 'macOS' && runner.arch != 'ARM64') + }} + shell: bash + run: | + echo "::error::installation not supported for ${{ runner.os }} on ${{ runner.arch }}" + echo "::error::please build locally with go or see available artifacts at https://github.com/gotestyourself/gotestsum/releases" + exit 1 - name: Check if runner is supported if: >- @@ -73,14 +87,12 @@ runs: mkdir -p "${DOWNLOAD_DIR}" ARCHIVE_FORMAT=".tar.gz" - # e.g. gotestsum_1.13.0_linux_amd64.tar.gz gh release download "${VERSION}" \ --repo "${REPO}" \ --pattern "*_${OS}_${ARCH}${ARCHIVE_FORMAT}" \ --output "${DOWNLOAD_DIR}"/"artifact${ARCHIVE_FORMAT}" - # should check checksum etc - if [[ "${OS}" == 'windows' ]] ; then + if [[ "${OS}" == "windows" ]] ; then TOOL="${TOOL}.exe" fi (cd "${DOWNLOAD_DIR}" && tar xf "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") diff --git a/install/svu/action.yml b/install/svu/action.yml new file mode 100644 index 0000000..0ae7c74 --- /dev/null +++ b/install/svu/action.yml @@ -0,0 +1,103 @@ +name: svu installer +description: | + Download the latest vetted version of svu. + + github.com/caarlos0/svu@{version} + +author: go-openapi + +inputs: + version: + description: | + State explicitly the version to be downloaded. + + By default the "auto" value uses the versions configured in "version.yaml" + required: false + default: auto + +outputs: + version: + description: The version of the tool that has been installed + value: ${{ steps.resolve-version.outputs.version }} + +runs: + using: composite + steps: + - + name: Check if runner is supported + if: >- + ${{ + (runner.os != 'Linux' && runner.os != 'macOS' && runner.os != 'Windows') || + (runner.os == 'Linux' && runner.arch != 'X64' ) || + (runner.os == 'Windows' && runner.arch != 'X64' ) || + (runner.os == 'macOS' && runner.arch != 'ARM64') + }} + shell: bash + run: | + echo "::error::installation not supported for ${{ runner.os }} on ${{ runner.arch }}" + echo "::error::please build locally with go or see available artifacts at https://github.com/gotestyourself/gotestsum/releases" + exit 1 + - + name: Resolve version + id: resolve-version + shell: bash + env: + TOOL: svu + VERSION_RESOLVER: '${{ github.action_path }}/../../get-tool-version.sh' + run: | + if [[ '${{ !inputs.version }}' == 'true' || '${{ inputs.version }}' == 'auto' ]] ; then + VERSION=$("${VERSION_RESOLVER}" "${TOOL}") + else + VERSION='${{ inputs.version }}' + fi + + if [[ -z "${VERSION}" ]] ; then + echo "::error::Could not resolve version for tool ${TOOL}" + exit 1 + fi + + echo "::notice title=Version:${VERSION}" + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + - + name: Install svu + shell: bash + env: + REPO: github.com/caarlos0/svu + TOOL: svu + VERSION: ${{ steps.resolve-version.outputs.version }} + DOWNLOAD_DIR: ${{ runner.temp }}/downloads + TARGET_DIR: ${{ github.action_path }}/bin + GH_TOKEN: ${{ github.token }} + run: | + OS=$(echo '${{ runner.os }}'|tr '[A-Z]' '[a-z]'|sed 's/macos/darwin/') + ARCH=$(echo '${{ runner.arch }}'|tr '[A-Z]' '[a-z]'|sed 's/x64/amd64/') + + mkdir -p "${DOWNLOAD_DIR}" + + ARCHIVE_FORMAT=".tar.gz" + if [[ "${OS}" == 'windows' ]] ; then + ARCHIVE_FORMAT=".zip" + elif [[ "${OS}" == 'darwin' ]] ; then + ARCH="all" + fi + + gh release download "${VERSION}" \ + --repo "${REPO}" \ + --pattern "*_${OS}_${ARCH}${ARCHIVE_FORMAT}" \ + --output "${DOWNLOAD_DIR}"/"artifact${ARCHIVE_FORMAT}" + + if [[ "${OS}" != 'windows' ]] ; then + (cd "${DOWNLOAD_DIR}" && tar xf "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") + else + TOOL="${TOOL}.exe" + (cd "${DOWNLOAD_DIR}" && unzip "artifact${ARCHIVE_FORMAT}" "${TOOL}" && rm -f "artifact${ARCHIVE_FORMAT}") + fi + + mkdir -p "${TARGET_DIR}" + mv "${DOWNLOAD_DIR}"/"${TOOL}" "${TARGET_DIR}" + + echo '${{ github.action_path }}/bin' >> "$GITHUB_PATH" + +branding: + icon: 'package' + color: 'blue' diff --git a/release_tracker.go b/release_tracker.go index 1dc0ba2..b2e2ffe 100644 --- a/release_tracker.go +++ b/release_tracker.go @@ -6,6 +6,7 @@ package main import ( // used to track dependencies using dependabot. + _ "github.com/caarlos0/svu/v3/pkg/svu" _ "github.com/ctrf-io/go-ctrf-json-reporter/ctrf" _ "github.com/jstemmer/go-junit-report/v2/gtr" _ "github.com/jstemmer/go-junit-report/v2/junit"