From fe70337cbb47d79a38be057f96c0b739717350af Mon Sep 17 00:00:00 2001 From: Tosin Samuel <68669102+TosinJs@users.noreply.github.com> Date: Wed, 13 Mar 2024 01:08:51 +0100 Subject: [PATCH] Fix Github Action Workflow (#7) (#8) * Fix Github Action Workflow * Debug Publish Script * verify Build * Fix Build * Use Updated Versions --- .github/workflows/publish.yml | 53 +++++++++++++++++++++++++++-------- .github/workflows/test.yml | 4 +-- package.json | 4 +-- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ceeb598..97e79af 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,35 +14,64 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Node.js environment - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: - node-version: '20' + node-version: 20 - name: Read version from package.json id: package_version - run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV + run: echo "RELEASE_TAG=$(node -p "require('./package.json').version")" >> $GITHUB_ENV - name: Create GitHub Release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: "actions/github-script@v7" with: - tag_name: v${{ env.PACKAGE_VERSION }} - release_name: Release v${{ env.PACKAGE_VERSION }} - draft: false - prerelease: false + github-token: "${{ secrets.GITHUB_TOKEN }}" + script: | + try { + const response = await github.rest.repos.createRelease({ + draft: false, + generate_release_notes: true, + name: process.env.RELEASE_TAG, + owner: context.repo.owner, + prerelease: false, + repo: context.repo.repo, + tag_name: process.env.RELEASE_TAG, + }); + + core.exportVariable('RELEASE_ID', response.data.id); + core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url); + } catch (error) { + core.setFailed(error.message); + } publish-npm: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: 20 registry-url: https://registry.npmjs.org + - run: | + if [ -z "${NODE_AUTH_TOKEN}" ]; then + echo "NODE_AUTH_TOKEN is not set." + exit 1 + else + echo "NODE_AUTH_TOKEN is set." + fi + + if [ -z "${WATSON_URL}" ]; then + echo "WATSON_URL is not set." + exit 1 + else + echo "WATSON_URL is set." + fi + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + WATSON_URL: ${{ secrets.WATSON_URL }} - run: npm ci - run: npm run build env: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb4a5ba..d5829e7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,8 +16,8 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: 20 - run: npm ci diff --git a/package.json b/package.json index 5f31c11..f96b089 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/gandalf-network/eyeofsauron.git" + "url": "git+https://github.com/gandalf-network/eyeofsauron.git" }, "dependencies": { "@graphql-codegen/cli": "^5.0.2", @@ -37,5 +37,5 @@ "dotenv": "^16.4.5", "jest": "^29.7.0", "ts-jest": "^29.1.2" - } + } }