From d0e7c8ab42277b9bff53e9dfd82684a12546a1e9 Mon Sep 17 00:00:00 2001 From: Emma Date: Wed, 15 May 2024 16:27:24 -0400 Subject: [PATCH] fix: Publish badge (#66) --- .github/workflows/publish.yml | 93 ----------------------- .github/workflows/release-and-publish.yml | 23 ++++-- Makefile | 22 ++++++ README.md | 2 +- 4 files changed, 38 insertions(+), 102 deletions(-) delete mode 100644 .github/workflows/publish.yml create mode 100644 Makefile diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 8d4e684..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Publish Packages -on: - release: - types: - - published - -jobs: - setup: - runs-on: ubuntu-latest - outputs: - do_dry_run: ${{ steps.variables.outputs.is_dry_run }} - environment: ${{ steps.variables.outputs.env }} - npm_package_version: ${{ steps.variables.outputs.version }} - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - - id: variables - run: | - local_version=$(npm pkg get version | sed 's/"//g') - hosted_version=$(npm show ts-mock-imports version) - if [[ $hosted_version == $local_version ]]; then - echo "is_dry_run=false" >> $GITHUB_OUTPUT - echo "version=$(npm pkg get version | sed 's/"//g')" >> $GITHUB_OUTPUT - echo "Creating release for ts-mock-imports at version $local_version" - else - echo "is_dry_run=true" >> $GITHUB_OUTPUT - fi - - - publish-npm: - needs: setup - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - # Setup .npmrc file to publish to npm - - uses: actions/setup-node@v4 - with: - registry-url: 'https://registry.npmjs.org' - - run: npm ci - - run: npm run compile - # Publish to npm - - run: | - if [[ ${{ needs.setup.outputs.do_dry_run }} == 'true' ]]; then - npm publish --access public --dry-run - else - npm publish --access public - fi - env: - NODE_AUTH_TOKEN: ${{ secrets.PUBLISH_NPM_TOKEN }} - - publish-gpr: - needs: setup - runs-on: ubuntu-latest - steps: - - run: echo ${{ needs.verify.outputs.do_dry_run }} - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - registry-url: https://npm.pkg.github.com/ - scope: '@emandm' - # Publish to GitHub Packages - - run: npm ci - - run: npm run compile - - - name: Update Package Name - run: | - sed -i 's,"name": "ts-mock-imports","name": "@emandm/ts-mock-imports",' package.json - cat package.json - - - run: echo registry=https://npm.pkg.github.com/emandm >> .npmrc - - run: | - if [[ ${{ needs.setup.outputs.do_dry_run }} == 'true' ]]; then - npm publish --dry-run - else - npm publish - fi - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - external_test: - runs-on: ubuntu-latest - needs: [setup, publish-npm] - if: ${{ needs.setup.outputs.do_dry_run }} == 'false' - steps: - - uses: actions/setup-node@v4 - - uses: actions/checkout@v4 - with: - repository: EmandM/import-test - - - run: npm ci - - run: npm uninstall ts-mock-imports # Ensure no contamination from existing version - - run: npm install ts-mock-imports@${{ needs.setup.outputs.npm_package_version }} - - run: npm test diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index d46a922..f1f4948 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -31,23 +31,30 @@ jobs: - run: npm run build - run: npm run lint - run: npm test + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + git_committer_name: github-actions[bot] + git_committer_email: 41898282+github-actions[bot]@users.noreply.github.com - id: update_version + name: Update Package Version run: | - date > generated.txt + echo foo > bar.txt set -e - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - if [[ ${{ inputs.prerelease }} ]]; then + # save the value would be created, then remove all changes new_version=$(npm version ${{ inputs.semver_type }} --no-commit-hooks --no-git-tag-version ) + git reset --hard else - new_version=$(npm version ${{ inputs.semver_type }} ) + new_version=$(npm version ${{ inputs.semver_type }} --sign-git-tag ) + git push && git push --tags fi echo "Created version ${new_version}" - - git push && git push --tags - echo "version_number=$new_version" >> $GITHUB_OUTPUT - id: pack_tar diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7f98e13 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +test: + npm test + +build: + npm run build + +check-next-version: + npm version --no-commit-hooks --no-git-tag-version patch + git reset --hard + +test-next-version: + npm pack + +pack: test-next-version + +RED := $(shell tput setaf 196) +RESET := $(shell tput setaf 15) + +release: build test-next-version check-next-version + echo "${RED}!! Run Release and Publish Github Action !!${RESET}" + +publish: release diff --git a/README.md b/README.md index 623fb5e..e50a6aa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ #### Intuitive mocking for Typescript imports. -[![npm](https://img.shields.io/npm/v/ts-mock-imports.svg)](https://www.npmjs.com/package/ts-mock-imports) [![Build Status](https://github.com/EmandM/ts-mock-imports/actions/workflows/publish.yml/badge.svg)](https://github.com/EmandM/ts-mock-imports/actions/workflows/publish.yml) [![Test Status](https://github.com/EmandM/ts-mock-imports/actions/workflows/test.yml/badge.svg)](https://github.com/EmandM/ts-mock-imports/actions/workflows/test.yml) +[![npm](https://img.shields.io/npm/v/ts-mock-imports.svg)](https://www.npmjs.com/package/ts-mock-imports) [![Build Status](https://github.com/EmandM/ts-mock-imports/actions/workflows/release-and-publish.yml/badge.svg)](https://github.com/EmandM/ts-mock-imports/actions/workflows/release-and-publish.yml) [![Test Status](https://github.com/EmandM/ts-mock-imports/actions/workflows/test.yml/badge.svg)](https://github.com/EmandM/ts-mock-imports/actions/workflows/test.yml) ## About