From d0b60c86fec200cdbe8c3e21aea14391dde37ea0 Mon Sep 17 00:00:00 2001 From: Bronley Plumb Date: Wed, 15 Nov 2023 14:59:19 -0500 Subject: [PATCH] try again --- .github/workflows/create-package.yml | 82 ++++++++++++---------------- 1 file changed, 35 insertions(+), 47 deletions(-) diff --git a/.github/workflows/create-package.yml b/.github/workflows/create-package.yml index e88f3a73..d924709b 100644 --- a/.github/workflows/create-package.yml +++ b/.github/workflows/create-package.yml @@ -7,70 +7,58 @@ jobs: runs-on: ubuntu-latest if: contains(github.event.pull_request.labels.*.name, 'create-package') steps: - # # Get a bot token so the bot's name shows up on all our actions - # - name: Get Token From roku-ci-token Application - # uses: tibdex/github-app-token@v1 - # id: generate-token - # with: - # app_id: ${{ secrets.BOT_APP_ID }} - # private_key: ${{ secrets.BOT_PRIVATE_KEY }} - # - name: Set New GitHub Token - # run: echo "TOKEN=${{ steps.generate-token.outputs.token }}" >> $GITHUB_ENV - - # - uses: actions/checkout@master - # - uses: actions/setup-node@master - # with: - # node-version: "14.19.0" - # - run: npm ci + - uses: actions/checkout@master + - uses: actions/setup-node@master + with: + node-version: "14.19.0" + # Get a bot token so the bot's name shows up on all our actions + - name: Get Token From roku-ci-token Application + uses: tibdex/github-app-token@v1 + id: generate-token + with: + app_id: ${{ secrets.BOT_APP_ID }} + private_key: ${{ secrets.BOT_PRIVATE_KEY }} + - run: echo "TOKEN=${{ steps.generate-token.outputs.token }}" >> $GITHUB_ENV + - name: Compute variables + run: | + CURRENT_VERSION=$(grep -o '\"version\": *\"[^\"]*\"' package.json | awk -F'\"' '{print $4}') - # - name: Compute variables - # run: | - # CURRENT_VERSION=$(grep -o '\"version\": *\"[^\"]*\"' package.json | awk -F'\"' '{print $4}') + BUILD_VERSION="$CURRENT_VERSION-alpha.$(date +%Y%m%d%H%M%S)" + echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV - # BUILD_VERSION="$CURRENT_VERSION-alpha.$(date +%Y%m%d%H%M%S)" - # echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV + NPM_PACKAGE_NAME=$(grep -o '\"name\": *\"[^\"]*\"' package.json | awk -F'\"' '{print $4}') - # NPM_PACKAGE_NAME=$(grep -o '\"name\": *\"[^\"]*\"' package.json | awk -F'\"' '{print $4}') + ARTIFACT_NAME=$(echo "$NPM_PACKAGE_NAME-$BUILD_VERSION.tgz" | tr '/' '-') + echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV - # ARTIFACT_NAME=$(echo "$NPM_PACKAGE_NAME-$BUILD_VERSION.tgz" | tr '/' '-') - # echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV + ARTIFACT_URL="${{ github.server_url }}/${{ github.repository }}/releases/download/v0.0.0-packages/${ARTIFACT_NAME} + echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV - # ARTIFACT_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - # echo "ARTIFACT_URL=$ARTIFACT_URL" >> $GITHUB_ENV + - run: npm ci + - run: npm version "$BUILD_VERSION" --no-git-tag-version + - run: npm pack - # - name: Update version and run pre-release scripts - # run: npm version "$BUILD_VERSION" --no-git-tag-version + - uses: actions/upload-artifact@v3 + with: + name: ${{ env.ARTIFACT_NAME }} + path: "*.tgz" - # - run: npm pack + # create the release if not exist + - run: gh release create v0.0.0-packages --notes "catchall release for temp packages" -R ${{ github.repository }} + continue-on-error: true - # - uses: actions/upload-artifact@v3 - # with: - # name: ${{ env.ARTIFACT_NAME }} - # path: "*.tgz" + # upload this artifact to the github release + - run: gh release upload v0.0.0-packages *.tgz -R rokucommunity/roku-debug - name: Fetch build artifact uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: 6871028938, - }) - .then((response) => { - const artifacts = response.data.artifacts; - console.log(artifacts); - return github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - //body: "Hey there! I just built a new temporary npm package based on ${{ github.event.pull_request.head.sha }}. You can download it from [this page](${{ env.ARTIFACT_URL }}) and then install it by running the following command: \n```bash\nnpm install ${{ env.ARTIFACT_NAME }}\n```" + //body: "Hey there! I just built a new temporary npm package based on ${{ github.event.pull_request.head.sha }}. You can download it [here](${{ env.ARTIFACT_URL }}) or install it by running the following command: \n```bash\nnpm install ${{ env.ARTIFACT_NAME }}\n```" body: JSON.stringify(artifacts) }); - - }) - .catch((error) => { - console.error('Error fetching data:', error); - });