1+ name : Initialize dspm
2+ description : Initialize dspm
3+
4+ inputs :
5+ ref :
6+ description : " The ref to checkout"
7+ required : false
8+ default : " main"
9+ build-dir :
10+ description : " The directory to build in"
11+ required : false
12+ default : ${{ runner.workspace }}/diffscope-package-manager
13+
14+ runs :
15+ using : " composite"
16+ steps :
17+ - name : Restore dspm executable cache
18+ id : cache_dspm
19+ uses : actions/cache/restore@v4
20+ with :
21+ path : ${{inputs.build-dir}}/dist
22+ key : ${{ runner.os }}-dspm-${{ inputs.ref }}-${{ github.sha }}
23+ restore-keys : |
24+ ${{ runner.os }}-dspm-${{ inputs.ref }}-
25+
26+ - name : Checkout
27+ if : steps.cache_dspm.outputs.cache-hit != 'true'
28+ shell : pwsh
29+ run : |
30+ git clone https://github.com/diffscope/diffscope-package-manager.git ${{inputs.build-dir}}
31+ cd ${{inputs.build-dir}}
32+ git checkout ${{ inputs.ref }}
33+
34+ - name : Setup Go
35+ uses : actions/setup-go@v6
36+ if : steps.cache_dspm.outputs.cache-hit != 'true'
37+ with :
38+ go-version-file : ${{inputs.build-dir}}/go.mod
39+ cache-dependency-path : ${{inputs.build-dir}}/go.sum
40+
41+ - name : Download dependencies
42+ if : steps.cache_dspm.outputs.cache-hit != 'true'
43+ working-directory : ${{ inputs.build-dir }}
44+ shell : pwsh
45+ run : go mod download
46+
47+ - name : Build
48+ if : steps.cache_dspm.outputs.cache-hit != 'true'
49+ working-directory : ${{ inputs.build-dir }}
50+ shell : pwsh
51+ run : |
52+ New-Item -ItemType Directory -Force dist | Out-Null
53+ $ext = if ($env:RUNNER_OS -eq 'Windows') { '.exe' } else { '' }
54+ go build -v -o "dist/dspm$ext" ./cmd/dspm
55+
56+ - name : Cache dspm executable
57+ uses : actions/cache/save@v4
58+ with :
59+ path : ${{inputs.build-dir}}/dist
60+ key : ${{ runner.os }}-dspm-${{ inputs.ref }}-${{ github.sha }}
61+
62+ - name : Output dspm path
63+ working-directory : ${{ inputs.build-dir }}
64+ shell : pwsh
65+ run : |
66+ $ext = if ($env:RUNNER_OS -eq 'Windows') { '.exe' } else { '' }
67+ Write-Output DSPM_EXECUTABLE_PATH=$(Resolve-Path dist/dspm$ext) >> $env:GITHUB_ENV
0 commit comments