From 81affa35a649ad09b14b4d8f3e48d1c1f7907894 Mon Sep 17 00:00:00 2001 From: Victorien Gauch <85494462+VGau@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:38:30 +0200 Subject: [PATCH] fix: remove authToken to build the ts-lib and remove github access token env variable from CI workflows (#18) Co-authored-by: Pedro Novais <1478752+jpnovais@users.noreply.github.com> --- .../workflows/postman-build-and-publish.yml | 1 - .github/workflows/postman-testing.yml | 1 - sdk/Dockerfile | 2 -- .../linea-native-libs/src/scripts/build.ts | 34 ++++++++----------- .../linea-native-libs/src/scripts/config.ts | 8 ----- 5 files changed, 15 insertions(+), 31 deletions(-) diff --git a/.github/workflows/postman-build-and-publish.yml b/.github/workflows/postman-build-and-publish.yml index 979eb8e2c..c59c8303b 100644 --- a/.github/workflows/postman-build-and-publish.yml +++ b/.github/workflows/postman-build-and-publish.yml @@ -70,5 +70,4 @@ jobs: cache-from: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache cache-to: type=registry,ref=${{ env.IMAGE_NAME }}:buildcache,mode=max build-args: | - GITHUB_API_ACCESS_TOKEN=${{ secrets._GITHUB_TOKEN_RELEASE_ACCESS }} NATIVE_LIBS_RELEASE_TAG=blob-libs-v1.0.1 diff --git a/.github/workflows/postman-testing.yml b/.github/workflows/postman-testing.yml index efff51e92..389639bf0 100644 --- a/.github/workflows/postman-testing.yml +++ b/.github/workflows/postman-testing.yml @@ -24,7 +24,6 @@ jobs: - name: Run tests and generate coverage report env: - GITHUB_API_ACCESS_TOKEN: ${{ secrets._GITHUB_TOKEN_RELEASE_ACCESS }} NATIVE_LIBS_RELEASE_TAG: blob-libs-v1.0.1 run: | pnpm run -F ./ts-libs/linea-native-libs build; diff --git a/sdk/Dockerfile b/sdk/Dockerfile index a608d2f40..fc733355c 100644 --- a/sdk/Dockerfile +++ b/sdk/Dockerfile @@ -9,9 +9,7 @@ FROM base AS builder WORKDIR /usr/src/app -ARG GITHUB_API_ACCESS_TOKEN ARG NATIVE_LIBS_RELEASE_TAG -ENV GITHUB_API_ACCESS_TOKEN=${GITHUB_API_ACCESS_TOKEN} ENV NATIVE_LIBS_RELEASE_TAG=${NATIVE_LIBS_RELEASE_TAG} COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json ./ diff --git a/ts-libs/linea-native-libs/src/scripts/build.ts b/ts-libs/linea-native-libs/src/scripts/build.ts index 4d7b6486c..8c88b5cc8 100644 --- a/ts-libs/linea-native-libs/src/scripts/build.ts +++ b/ts-libs/linea-native-libs/src/scripts/build.ts @@ -22,10 +22,10 @@ async function downloadAndParseJson(url: string, headers: Record return await response.json(); } -async function getReleaseAssetUrl(authToken: string, nativeLibReleaseTag: string): Promise { - const urlStr = "https://api.github.com/repos/ConsenSys/zkevm-monorepo/releases"; +async function getReleaseAssetUrl(nativeLibReleaseTag: string): Promise { + const urlStr = "https://api.github.com/repos/Consensys/linea-monorepo/releases"; - const json = await downloadAndParseJson(urlStr, { Authorization: `token ${authToken}` }); + const json = await downloadAndParseJson(urlStr); const release = json.find((release: any) => release.tag_name === nativeLibReleaseTag); if (!release) { @@ -38,15 +38,15 @@ async function getReleaseAssetUrl(authToken: string, nativeLibReleaseTag: string } const asset = release.assets.find((asset: any) => asset.name.includes(nativeLibReleaseTag)); - return `https://${authToken}:@api.github.com/repos/Consensys/zkevm-monorepo/releases/assets/${asset.id}`; + return `https://api.github.com/repos/Consensys/linea-monorepo/releases/assets/${asset.id}`; } -async function downloadFileUsingCurl(authToken: string, url: string, outputFilePath: string): Promise { +async function downloadFileUsingCurl(url: string, outputFilePath: string): Promise { const outputDirectory = path.dirname(outputFilePath); // Ensure the output directory exists fs.mkdirSync(outputDirectory, { recursive: true }); - const command = `curl -L -H 'Accept:application/octet-stream' -u ${authToken}: -o ${outputFilePath} ${url}`; + const command = `curl -L -H 'Accept:application/octet-stream' -o ${outputFilePath} ${url}`; return new Promise((resolve, reject) => { exec(command, (error: any, _: any, stderr: any) => { @@ -67,12 +67,12 @@ const architectureResourceDirMapping: Record = { linux_x86_64: "linux-x64", }; -async function downloadReleaseAsset(authToken: string, nativeLibReleaseTag: string): Promise { - const assetReleaseUrl = await getReleaseAssetUrl(authToken, nativeLibReleaseTag); +async function downloadReleaseAsset(nativeLibReleaseTag: string): Promise { + const assetReleaseUrl = await getReleaseAssetUrl(nativeLibReleaseTag); const fileName = `${nativeLibReleaseTag}.zip`; const destPath = path.resolve("build", fileName); console.log(`Downloading ${fileName} from ${assetReleaseUrl} to ${destPath}`); - return await downloadFileUsingCurl(authToken, assetReleaseUrl, destPath); + return await downloadFileUsingCurl(assetReleaseUrl, destPath); } function getBinaryResourceFolder(libFile: string): string { @@ -91,12 +91,8 @@ function getBinaryResourceFileName(libFile: string, libName: string): string { return `${libName}_${version}${extension}`; } -async function downloadReleaseAndExtractToResources( - authToken: string, - nativeLibReleaseTag: string, - libName: string, -): Promise { - const outputFile = await downloadReleaseAsset(authToken, nativeLibReleaseTag); +async function downloadReleaseAndExtractToResources(nativeLibReleaseTag: string, libName: string): Promise { + const outputFile = await downloadReleaseAsset(nativeLibReleaseTag); if (!fs.existsSync(outputFile)) { throw new Error(`Output file ${outputFile} does not exist`); @@ -127,13 +123,13 @@ async function downloadReleaseAndExtractToResources( } } -async function fetchLib(authToken: string, nativeLibReleaseTag: string, libName: string): Promise { - await downloadReleaseAndExtractToResources(authToken, nativeLibReleaseTag, libName); +async function fetchLib(nativeLibReleaseTag: string, libName: string): Promise { + await downloadReleaseAndExtractToResources(nativeLibReleaseTag, libName); } async function main() { - const { authToken, nativeLibReleaseTag } = getBuildConfig(); - await fetchLib(authToken, nativeLibReleaseTag, "blob_compressor"); + const { nativeLibReleaseTag } = getBuildConfig(); + await fetchLib(nativeLibReleaseTag, "blob_compressor"); } main() diff --git a/ts-libs/linea-native-libs/src/scripts/config.ts b/ts-libs/linea-native-libs/src/scripts/config.ts index 158e46920..8ebc637bf 100644 --- a/ts-libs/linea-native-libs/src/scripts/config.ts +++ b/ts-libs/linea-native-libs/src/scripts/config.ts @@ -3,17 +3,10 @@ import { config } from "dotenv"; config(); type BuildConfig = { - authToken: string; nativeLibReleaseTag: string; }; export function getBuildConfig(): BuildConfig { - const authToken = process.env.GITHUB_API_ACCESS_TOKEN; - - if (!authToken) { - throw new Error("GITHUB_API_ACCESS_TOKEN environment variable is not set"); - } - const nativeLibReleaseTag = process.env.NATIVE_LIBS_RELEASE_TAG; if (!nativeLibReleaseTag) { @@ -21,7 +14,6 @@ export function getBuildConfig(): BuildConfig { } return { - authToken, nativeLibReleaseTag, }; }