diff --git a/README.md b/README.md index 98ce849..3222f4d 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,11 @@ Reduce all these workflow steps: ```yaml steps: - name: Setup Golang - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ~1.20 - name: Setup Golang caches - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cache/go-build @@ -34,9 +34,9 @@ down to this: ```yaml steps: - name: Setup Golang with cache - uses: magnetikonline/action-golang-cache@v4 + uses: magnetikonline/action-golang-cache@v5 with: - go-version: ~1.20 + go-version: ~1.22 ``` or better yet, use `go-version-file` for version selection: @@ -44,7 +44,7 @@ or better yet, use `go-version-file` for version selection: ```yaml steps: - name: Setup Golang with cache - uses: magnetikonline/action-golang-cache@v4 + uses: magnetikonline/action-golang-cache@v5 with: go-version-file: go.mod ``` @@ -58,9 +58,9 @@ An optional `cache-key-suffix` input allows control of the generated cache key. ```yaml steps: - name: Cache key suffix - uses: magnetikonline/action-golang-cache@v4 + uses: magnetikonline/action-golang-cache@v5 with: - go-version: ~1.20 + go-version: ~1.22 cache-key-suffix: apples # cache key: ${{ runner.os }}-golang-apples-${{ hashFiles('**/go.sum') }} @@ -75,7 +75,7 @@ Outputs of `build-cache-path`, `module-cache-path` and `cache-key` are provided steps: - name: Setup Golang with cache id: golang-with-cache - uses: magnetikonline/action-golang-cache@v4 + uses: magnetikonline/action-golang-cache@v5 with: go-version-file: go.mod @@ -83,7 +83,7 @@ steps: - name: Save Golang cache if: always() - uses: actions/cache/save@v3 + uses: actions/cache/save@v4 with: path: | ${{ steps.golang-with-cache.outputs.build-cache-path }} diff --git a/action.yaml b/action.yaml index 994e7cf..e803453 100644 --- a/action.yaml +++ b/action.yaml @@ -1,12 +1,14 @@ name: Golang with cache author: Peter Mescalchin -description: Setup requested Golang version with enabled module and build caching. +description: Setup requested Golang version with managed module and build caching. inputs: go-version: description: Desired Golang version. + default: go-version-file: description: Path to go.mod file, will determine Golang version. Use in place of `go-version` input. + default: cache-key-suffix: description: Optional cache key suffix. default: @@ -26,7 +28,7 @@ runs: using: composite steps: - name: Setup Golang - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: cache: false go-version: ${{ inputs.go-version }} @@ -36,12 +38,12 @@ runs: run: | echo "build-cache-path=$(go env GOCACHE)" >>"$GITHUB_OUTPUT" echo "module-cache-path=$(go env GOMODCACHE)" >>"$GITHUB_OUTPUT" - cacheKeyRoot="${{ runner.os }}-golang${{ inputs.cache-key-suffix && '-' }}${{ inputs.cache-key-suffix }}-" + cacheKeyRoot="${{ runner.os }}-golang${{ inputs.cache-key-suffix && format('-{0}',inputs.cache-key-suffix) }}-" echo "cache-key-restore=$cacheKeyRoot" >>"$GITHUB_OUTPUT" echo "cache-key=${cacheKeyRoot}${{ hashFiles('**/go.sum') }}" >>"$GITHUB_OUTPUT" shell: bash - name: Setup Golang cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ${{ steps.golang-env.outputs.build-cache-path }}