From c7188a34fae0ee31c13a2e1386c3f6815d6855ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Zieli=C5=84ski?= Date: Wed, 12 Feb 2025 18:07:21 +0100 Subject: [PATCH] WIP: Build & Release --- .github/workflows/build.yml | 13 +++++++++++- .../workflows/buildScripts/replaceTokens.js | 3 --- .github/workflows/release-morska.yml | 21 +++++++++++++++++-- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06476d4..5a89c65 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,20 +6,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@master with: node-version: 20 + - name: Install Angular CLI run: yarn global add @angular/cli + - name: Configure ng to use yarn run: ng config --global cli.packageManager yarn + - name: Yarn install working-directory: Frontend run: yarn install + - name: Build Angular working-directory: Frontend run: ng build --configuration=production + - name: Upload artifact uses: actions/upload-artifact@v4 with: @@ -30,23 +36,28 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Setup dotnet 9 uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x + - name: Install dependencies working-directory: WebAPI run: dotnet restore + - name: Build working-directory: WebAPI run: | dotnet build --configuration Release --no-restore - dotnet publish --configuration Release --framework net9.0 --runtime linux-x64 --self-contained false --output ./WebApiBuild + dotnet publish --configuration Release --framework net9.0 --runtime linux-x64 --self-contained false --output ./WebApiBuild + - name: Clean up working-directory: WebAPI run: | rm ./WebApiBuild/appsettings.Development.json rm ./WebApiBuild/client_secrets.Development.json + - name: Upload artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/buildScripts/replaceTokens.js b/.github/workflows/buildScripts/replaceTokens.js index 8b4cd1d..4d9b57f 100644 --- a/.github/workflows/buildScripts/replaceTokens.js +++ b/.github/workflows/buildScripts/replaceTokens.js @@ -17,14 +17,11 @@ module.exports = async ({ github, context, core, jobId }) => { let match; while (match = regex.exec(data)) { const token = match[1].replace(/-/g, '_').toUpperCase(); - console.log(token); const value = getValue(token, jobId); - console.log(value); if (!value) { core.setFailed(`Token ${token} not found`); return false; } - // replace all occurrences of the ${token} with the value in file const result = data.replace(new RegExp(`#{${token}}`, 'g'), value); require('fs').writeFileSync(file, result, 'utf8'); } diff --git a/.github/workflows/release-morska.yml b/.github/workflows/release-morska.yml index b8a078c..614d8f6 100644 --- a/.github/workflows/release-morska.yml +++ b/.github/workflows/release-morska.yml @@ -17,9 +17,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Assign run ID if provided if: ${{ github.event.inputs.job_id != '' }} run: echo "job_id=${{ github.event.inputs.job_id }}" >> $GITHUB_ENV + - name: Get last build ID id: get-build-id if: ${{ github.event.inputs.job_id == '' }} @@ -29,6 +31,7 @@ jobs: const script = require('./.github/workflows/buildScripts/getLastBuildId.js'); const jobId = await script({github, context}); core.setOutput("job_id", jobId); + - name: Set job_id if: ${{ github.event.inputs.job_id == '' }} run: echo "job_id=${{ steps.get-build-id.outputs.job_id }}" >> $GITHUB_ENV @@ -38,20 +41,21 @@ jobs: echo "Error: job_id is empty" exit 1 fi + - name: Download frontend artifacts uses: actions/github-script@v6 with: script: | const script = require('./.github/workflows/buildScripts/downloadArtifacts.js'); await script({github, context, core, jobId: ${{env.job_id}}, name: 'frontend'}); + - name: Download backend artifacts uses: actions/github-script@v6 with: script: | const script = require('./.github/workflows/buildScripts/downloadArtifacts.js'); await script({github, context, core, jobId: ${{env.job_id}}, name: 'webapi'}); - - name: List artifacts - run: ls -laR ./${{env.job_id}} + - name: Tokenize uses: actions/github-script@v6 env: @@ -61,3 +65,16 @@ jobs: script: | const script = require('./.github/workflows/buildScripts/replaceTokens.js'); await script({github, context, core, jobId: ${{env.job_id}} }); + + - name: Archive frontend artifacts + run: | + cd ${{env.job_id}}/frontend + zip -r ../morska-frontend.zip . + + - name: Archive backend artifacts + run: | + cd ${{env.job_id}}/webapi + zip -r ../morska-webapi.zip . + + - name: List artifacts + run: ls -la .