Skip to content

Commit

Permalink
Check if tool has been already downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
bayrakmustafa committed Oct 30, 2023
1 parent ae032d3 commit 76cc861
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 17 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,60 @@ jobs:
name: sign-external.ps1
path: ./artifacts/codesign.ps1

sign-multi-same-job:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
runs-on: ${{ matrix.os }}
needs: ['build']
steps:
- uses: actions/checkout@v3

- name: Create Input file for test signing
shell: bash
run: |
mkdir -p ${GITHUB_WORKSPACE}/example
echo 'Write-Output -InputObject "Happy Signing From ESigner.com!"' > ${GITHUB_WORKSPACE}/example/codesign1.ps1
echo 'Write-Output -InputObject "Happy Signing From ESigner.com!"' > ${GITHUB_WORKSPACE}/example/codesign2.ps1
- uses: ./
with:
command: sign
username: ${{ secrets.ES_USERNAME }}
password: ${{ secrets.ES_PASSWORD }}
credential_id: ${{ secrets.CREDENTIAL_ID }}
totp_secret: ${{ secrets.ES_TOTP_SECRET }}
file_path: ${GITHUB_WORKSPACE}/example/codesign1.ps1
output_path: ${GITHUB_WORKSPACE}/artifacts
malware_block: false
environment_name: TEST
jvm_max_memory: 2048M

- uses: ./
with:
command: sign
username: ${{ secrets.ES_USERNAME }}
password: ${{ secrets.ES_PASSWORD }}
credential_id: ${{ secrets.CREDENTIAL_ID }}
totp_secret: ${{ secrets.ES_TOTP_SECRET }}
file_path: ${GITHUB_WORKSPACE}/example/codesign2.ps1
output_path: ${GITHUB_WORKSPACE}/artifacts
malware_block: false
environment_name: TEST
jvm_max_memory: 2048M

- name: Upload Signed Files (1)
uses: actions/upload-artifact@v3
with:
name: sign.ps1
path: ./artifacts/codesign1.ps1

- name: Upload Signed Files (2)
uses: actions/upload-artifact@v3
with:
name: sign.ps1
path: ./artifacts/codesign2.ps1

batch-sign:
strategy:
matrix:
Expand Down
23 changes: 15 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const UNIX = 'UNIX';
export const MACOS = 'MACOS';
export const WINDOWS = 'WINDOWS';
export const CODESIGNTOOL_VERSION = 'v1.2.7';
export const CODESIGNTOOL_BASEPATH = `CodeSignTool-${CODESIGNTOOL_VERSION}`;

export const CODESIGNTOOL_WINDOWS_SETUP = `https://github.com/SSLcom/CodeSignTool/releases/download/${CODESIGNTOOL_VERSION}/CodeSignTool-${CODESIGNTOOL_VERSION}-windows.zip`;
export const CODESIGNTOOL_UNIX_SETUP = `https://github.com/SSLcom/CodeSignTool/releases/download/${CODESIGNTOOL_VERSION}/CodeSignTool-${CODESIGNTOOL_VERSION}.zip`;
Expand Down
24 changes: 16 additions & 8 deletions src/setup-codesigner/codesigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
INPUT_PASSWORD,
INPUT_CREDENTIAL_ID,
INPUT_PROGRAM_NAME,
ACTION_SCAN_CODE
ACTION_SCAN_CODE,
CODESIGNTOOL_BASEPATH
} from '../constants';
import { CODESIGNTOOL_PROPERTIES, CODESIGNTOOL_DEMO_PROPERTIES } from '../config';

Expand All @@ -37,15 +38,22 @@ export class CodeSigner {

const codesigner = path.resolve(process.cwd(), 'codesign');
core.info(`Creating CodeSignTool extract path ${codesigner}`);
mkdirSync(codesigner);
if (!existsSync(codesigner)) {
mkdirSync(codesigner);
core.info(`Created CodeSignTool extract path ${codesigner}`);
}

let archivePath = path.join(codesigner, CODESIGNTOOL_BASEPATH);
if (!existsSync(archivePath)) {
const downloadedFile = await tc.downloadTool(link);
await extractZip(downloadedFile, codesigner);
core.info(`Extract CodeSignTool from download path ${downloadedFile} to ${codesigner}`);

const downloadedFile = await tc.downloadTool(link);
const extractedCodeSignPath = await extractZip(downloadedFile, codesigner);
core.info(`Extract CodeSignTool from download path ${downloadedFile} to ${codesigner}`);
const archiveName = fs.readdirSync(codesigner)[0];
archivePath = path.join(codesigner, archiveName);
}

const archiveName = fs.readdirSync(extractedCodeSignPath)[0];
const archivePath = path.join(extractedCodeSignPath, archiveName);
core.info(`Archive name: ${archiveName}, ${archivePath}`);
core.info(`Archive name: ${CODESIGNTOOL_BASEPATH}, ${archivePath}`);
listFiles(archivePath);

const environment = core.getInput(INPUT_ENVIRONMENT_NAME) ?? PRODUCTION_ENVIRONMENT_NAME;
Expand Down

0 comments on commit 76cc861

Please sign in to comment.