Skip to content

Commit 43db50b

Browse files
feat: build for release
1 parent 5cc54a7 commit 43db50b

2 files changed

Lines changed: 35 additions & 61 deletions

File tree

action.yml

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,23 @@ inputs:
8686
skip-uncommitted-files-check:
8787
required: false
8888
description: "Skip validation of uncommitted changes"
89+
skip-container-engine-check:
90+
required: false
91+
description: "Skip check for the presence of a known container engine before executing"
8992
runs:
9093
using: "composite"
9194
steps:
9295
- name: "Set Global Variables"
9396
shell: bash
9497
run: |
95-
echo "CODACY_BASE_URL_OR_DEFAULT=$(if [ ${{ inputs.codacy-api-base-url }} ]; then echo "${{ inputs.codacy-api-base-url }}"; else echo "https://api.codacy.com"; fi)" >> $GITHUB_ENV
96-
echo "OWNER_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 1)" >> $GITHUB_ENV
97-
echo "REPOSITORY_NAME=$(echo $GITHUB_REPOSITORY | cut -d '/' -f 2)" >> $GITHUB_ENV
98-
echo "ORGANIZATION_PROVIDER=$(if [ "$GITHUB_SERVER_URL" == "https://github.com" ]; then echo "gh"; else echo "ghe"; fi)" >> $GITHUB_ENV
99-
echo "COMMIT_SHA=$(if [ ${{ github.event_name }} == "pull_request" ]; then echo "${{ github.event.pull_request.head.sha }}"; else echo "${{ github.sha }}"; fi)" >> $GITHUB_ENV
98+
echo "CODACY_BASE_URL_OR_DEFAULT=$(if [ -n "${{ inputs.codacy-api-base-url }}" ]; then echo "${{ inputs.codacy-api-base-url }}"; else echo "https://api.codacy.com"; fi)" >> "$GITHUB_ENV"
99+
echo "OWNER_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d '/' -f 1)" >> "$GITHUB_ENV"
100+
echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d '/' -f 2)" >> "$GITHUB_ENV"
101+
echo "ORGANIZATION_PROVIDER=$(if [ "$GITHUB_SERVER_URL" == "https://github.com" ]; then echo "gh"; else echo "ghe"; fi)" >> "$GITHUB_ENV"
102+
echo "COMMIT_SHA=$(if [ "${{ github.event_name }}" == "pull_request" ]; then echo "${{ github.event.pull_request.head.sha }}"; else echo "${{ github.sha }}"; fi)" >> "$GITHUB_ENV"
103+
if [ -n "${{ inputs.skip-container-engine-check }}" ]; then
104+
echo "SKIP_CONTAINER_ENGINE_CHECK=${{ inputs.skip-container-engine-check }}" >> "$GITHUB_ENV"
105+
fi
100106
101107
- name: "Prepare curl authentication header"
102108
shell: bash
@@ -105,7 +111,7 @@ runs:
105111
echo "CURL_CODACY_AUTH_AUTHENTICATION=api-token: ${{ inputs.api-token }}" >> $GITHUB_ENV
106112
elif [ -n "${{ inputs.project-token }}" ]; then
107113
echo "CURL_CODACY_AUTH_AUTHENTICATION=project-token: ${{ inputs.project-token }}" >> $GITHUB_ENV
108-
elif [ ${{ inputs.upload }} = true ]; then
114+
elif [ "${{ inputs.upload }}" == "true" ]; then
109115
echo "At least one authentication method is required to upload results."
110116
exit 1
111117
fi
@@ -117,7 +123,7 @@ runs:
117123
118124
if [ "${{ inputs.run-gosec }}" == "true" ]; then
119125
cd /tmp
120-
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s v2.13.1
126+
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s v2.15.0
121127
chmod +x ./bin/gosec
122128
CODACY_GOSEC_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-gosec/latest" -o-)
123129
curl -fsSL "https://artifacts.codacy.com/bin/codacy-gosec/$CODACY_GOSEC_VERSION/codacy-gosec-$CODACY_GOSEC_VERSION" -o /tmp/codacy-gosec
@@ -126,7 +132,7 @@ runs:
126132
127133
/tmp/bin/gosec -no-fail -fmt json -log /tmp/log.txt ./... > /tmp/gosec-out.json
128134
/tmp/codacy-gosec < /tmp/gosec-out.json > /tmp/codacy-out.json
129-
if [ ${{ inputs.upload }} = true ]; then
135+
if [ "${{ inputs.upload }}" == "true" ]; then
130136
curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \
131137
-H "Content-type: application/json" --data-binary @/tmp/codacy-out.json \
132138
"${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/issuesRemoteResults"
@@ -136,28 +142,27 @@ runs:
136142
else
137143
echo "Skipping GoSec"
138144
fi
139-
145+
- name: set-up go
146+
uses: actions/setup-go@v3
147+
with:
148+
go-version: 1.20.2
140149
- name: "Run StaticCheck"
141150
shell: bash
142151
run: |
143152
set -eux
144153
145154
if [ "${{ inputs.run-staticcheck }}" == "true" ]; then
146155
cd /tmp
147-
curl -fsSL https://api.github.com/repos/dominikh/go-tools/releases/latest \
148-
| grep -E "browser_download_url.*staticcheck_linux_amd64.tar.gz\"$" \
149-
| cut -d '"' -f 4 \
150-
| xargs -L 1 curl -fsSL -o /tmp/staticcheck_linux_amd64.tar.gz
151-
tar -xvf /tmp/staticcheck_linux_amd64.tar.gz staticcheck/staticcheck
152-
chmod +x ./staticcheck/staticcheck
156+
go install honnef.co/go/tools/cmd/staticcheck@2023.1.6
157+
chmod +x /home/runner/go/bin/staticcheck
153158
CODACY_STATICCHECK_VERSION=$(curl -SL "https://artifacts.codacy.com/bin/codacy-staticcheck/latest" -o-)
154159
curl -fsSL "https://artifacts.codacy.com/bin/codacy-staticcheck/$CODACY_STATICCHECK_VERSION/codacy-staticcheck-$CODACY_STATICCHECK_VERSION" -o /tmp/codacy-staticcheck
155160
chmod +x /tmp/codacy-staticcheck
156161
cd -
157162
158-
find . -type f -name go.mod -exec bash -c 'cd $(dirname $1); cp $1 $1.codacy.bak; PKGS=$(go list ./...); /tmp/staticcheck/staticcheck -f json $PKGS; mv $1.codacy.bak $1' _ {} \; > /tmp/staticcheck-out.json
163+
find . -type f -name go.mod -exec bash -c 'cd $(dirname $1); cp $1 $1.codacy.bak; PKGS=$(go list ./...); /home/runner/go/bin/staticcheck -f json $PKGS; mv $1.codacy.bak $1' _ {} \; > /tmp/staticcheck-out.json
159164
/tmp/codacy-staticcheck < /tmp/staticcheck-out.json > /tmp/codacy-out.json
160-
if [ ${{ inputs.upload }} = true ]; then
165+
if [ "${{ inputs.upload }}" == "true" ]; then
161166
curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \
162167
-H "Content-type: application/json" --data-binary @/tmp/codacy-out.json \
163168
"${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/issuesRemoteResults"
@@ -181,7 +186,7 @@ runs:
181186
cd -
182187
183188
/tmp/codacy-clang-tidy < "${{ inputs.clang-tidy-output }}" > /tmp/codacy-out.json
184-
if [ ${{ inputs.upload }} = true ]; then
189+
if [ "${{ inputs.upload }}" == "true" ]; then
185190
curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \
186191
-H "Content-type: application/json" --data-binary @/tmp/codacy-out.json \
187192
"${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/issuesRemoteResults"
@@ -205,7 +210,7 @@ runs:
205210
cd -
206211
207212
/tmp/codacy-faux-pas < "${{ inputs.faux-pas-output }}" > /tmp/codacy-out.json
208-
if [ ${{ inputs.upload }} = true ]; then
213+
if [ "${{ inputs.upload }}" == "true" ]; then
209214
curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \
210215
-H "Content-type: application/json" --data-binary @/tmp/codacy-out.json \
211216
"${CODACY_BASE_URL_OR_DEFAULT}/2.0/$ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME/commit/$COMMIT_SHA/issuesRemoteResults"
@@ -218,7 +223,7 @@ runs:
218223
219224
- name: "Set Codacy CLI version"
220225
shell: bash
221-
run: echo "CODACY_ANALYSIS_CLI_VERSION=7.6.4" >> $GITHUB_ENV
226+
run: echo "CODACY_ANALYSIS_CLI_VERSION=7.9.7" >> $GITHUB_ENV
222227
- name: "Set script path environment variable"
223228
shell: bash
224229
run: echo "CLI_SCRIPT_PATH=${{ github.action_path }}/codacy-analysis-cli.sh" >> $GITHUB_ENV
@@ -227,7 +232,7 @@ runs:
227232
run: wget -O - https://raw.githubusercontent.com/codacy/codacy-analysis-cli/${{ env.CODACY_ANALYSIS_CLI_VERSION }}/bin/codacy-analysis-cli.sh > ${{ env.CLI_SCRIPT_PATH }}
228233
- name: "Change Codacy CLI script permissions"
229234
shell: bash
230-
run: chmod +x ${{ env.CLI_SCRIPT_PATH }}
235+
run: chmod +x "${{ env.CLI_SCRIPT_PATH }}"
231236
- name: "Run Codacy CLI"
232237
shell: bash
233238
run: |
@@ -236,7 +241,7 @@ runs:
236241
analyze \
237242
--skip-commit-uuid-validation \
238243
--commit-uuid $COMMIT_SHA \
239-
$(if [ "${{ inputs.verbose }}" = "true" ]; then echo "--verbose"; fi) \
244+
$(if [ "${{ inputs.verbose }}" == "true" ]; then echo "--verbose"; fi) \
240245
$(if [ -n "${{ inputs.project-token }}" ]; then echo "--project-token ${{ inputs.project-token }}"; fi) \
241246
$(if [ -n "${{ inputs.api-token }}" ]; then echo "--api-token ${{ inputs.api-token }} --username $OWNER_NAME --project $REPOSITORY_NAME --provider $ORGANIZATION_PROVIDER"; fi) \
242247
$(if [ -n "${{ inputs.codacy-api-base-url }}" ]; then echo "--codacy-api-base-url ${{ inputs.codacy-api-base-url }}"; fi) \
@@ -248,21 +253,21 @@ runs:
248253
$(if [ -n "${{ inputs.max-allowed-issues }}" ]; then echo "--max-allowed-issues ${{ inputs.max-allowed-issues }}"; fi) \
249254
$(if [ -n "${{ inputs.tool }}" ]; then echo "--tool ${{ inputs.tool }}"; fi) \
250255
$(if [ -n "${{ inputs.tool-timeout }}" ]; then echo "--tool-timeout ${{ inputs.tool-timeout }}"; fi) \
251-
$(if [ "${{ inputs.skip-uncommitted-files-check }}" = "true" ]; then echo "--skip-uncommitted-files-check"; fi) \
252-
$(if [ "${{ inputs.upload }}" = "true" ]; then echo "--upload"; fi) \
256+
$(if [ "${{ inputs.skip-uncommitted-files-check }}" == "true" ]; then echo "--skip-uncommitted-files-check"; fi) \
257+
$(if [ "${{ inputs.upload }}" == "true" ]; then echo "--upload"; fi) \
253258
$(if [ -n "${{ inputs.upload-batch-size }}" ]; then echo "--upload-batch-size ${{ inputs.upload-batch-size }}"; fi) \
254-
$(if [ "${{ inputs.fail-if-incomplete }}" = "true" ]; then echo "--fail-if-incomplete"; fi) \
255-
$(if [ "${{ inputs.allow-network }}" = "true" ]; then echo "--allow-network"; fi) \
256-
$(if [ "${{ inputs.force-file-permissions }}" = "true" ]; then echo "--force-file-permissions"; fi) \
257-
$(if [ "${{ inputs.gh-code-scanning-compat }}" = "true" ]; then echo "--gh-code-scanning-compat"; fi)
259+
$(if [ "${{ inputs.fail-if-incomplete }}" == "true" ]; then echo "--fail-if-incomplete"; fi) \
260+
$(if [ "${{ inputs.allow-network }}" == "true" ]; then echo "--allow-network"; fi) \
261+
$(if [ "${{ inputs.force-file-permissions }}" == "true" ]; then echo "--force-file-permissions"; fi) \
262+
$(if [ "${{ inputs.gh-code-scanning-compat }}" == "true" ]; then echo "--gh-code-scanning-compat"; fi)
258263
else
259264
echo "Skipping docker tools"
260265
fi
261266
262267
- name: "Let Codacy know it can start processing the analysis results"
263268
shell: bash
264269
run: |
265-
if [ ${{ inputs.upload }} = true ]; then
270+
if [ "${{ inputs.upload }}" == "true" ]; then
266271
echo "Uploading results for $ORGANIZATION_PROVIDER/$OWNER_NAME/$REPOSITORY_NAME commit $COMMIT_SHA"
267272
curl -XPOST -L -H "$CURL_CODACY_AUTH_AUTHENTICATION" \
268273
-H "Content-type: application/json" \

images/codacy-logo.svg

Lines changed: 1 addition & 32 deletions
Loading

0 commit comments

Comments
 (0)