name: Reusable Create Release on: workflow_call: inputs: changelog_file: description: Name of changelog file. type: string required: false default: NEWS.md workflows: description: Comma-delimited list of workflows to check type: string required: false default: ci-workflow.yml build: description: Flag to run `npm run build` before publishing type: boolean required: false default: false permissions: # This permission is needed so that git tags can be created. contents: write # This permission is needed for OIDC based publishing. id-token: write jobs: tag-and-publish: environment: release-approval runs-on: ubuntu-latest steps: # Check out caller repo - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # check out agent repo to agent-repo for the bin folders - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: repository: newrelic/node-newrelic path: agent-repo - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: lts/* check-latest: true registry-url: 'https://registry.npmjs.org' # Only need to install deps in agent-repo because of the bin scripts - name: Install Dependencies run: | # Install deps in caller repo npm install # Install deps in agent repo npm install --prefix agent-repo - name: Build project if: ${{ inputs.build }} run: npm run build - name: Setup GitHub Credentials run: | git config user.name $GITHUB_ACTOR git config user.email gh-actions-${GITHUB_ACTOR}@github.com - name: Create Release Tag run: node ./agent-repo/bin/create-release-tag.js --branch "$BRANCH" --repo "$REPO" --workflows "$WORKFLOWS" env: BRANCH: ${{ github.ref }} REPO: ${{ github.repository }} WORKFLOWS: ${{ inputs.workflows }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Publish to Npm run: npm publish - name: Get Created Tag id: get_tag run: echo "latest_tag=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT - name: Create GitHub Release run: node ./agent-repo/bin/create-github-release.js --tag "$LATEST_TAG" --repo "$REPO" --changelog "$CHANGELOG_FILE" env: LATEST_TAG: ${{ steps.get_tag.outputs.latest_tag }} REPO: ${{ github.repository }} CHANGELOG_FILE: ${{ inputs.changelog_file }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}