-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from arcezd/main
update documentation and github release pipeline
- Loading branch information
Showing
2 changed files
with
140 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Create new release | ||
name: Generate and publish NPM package | ||
|
||
on: | ||
push: | ||
|
@@ -7,62 +7,145 @@ on: | |
- 'beta' | ||
|
||
jobs: | ||
release: | ||
|
||
package: | ||
name: Generate new package | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
version: ${{ steps.vars.outputs.version }} | ||
git-tag: ${{ steps.vars.outputs.git-tag }} | ||
release-filename: ${{ steps.vars.outputs.release-filename }} | ||
artifact-name: ${{ steps.vars.outputs.artifact-name }} | ||
steps: | ||
- name: Checkout repo | ||
id: checkout | ||
uses: actions/checkout@v3 | ||
- name: Use Node.js | ||
id: use-nodejs | ||
uses: actions/setup-node@v3 | ||
- name: Import GPG key for bot | ||
id: bot-signing-key | ||
uses: crazy-max/ghaction-import-gpg@v4 | ||
with: | ||
node-version: '14.x' | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Install dependencies | ||
id: install-dependencies | ||
run: yarn install --frozen-lockfile | ||
- name: Execute tests | ||
id: yarn-test | ||
run: yarn test | ||
- name: Prepare git user | ||
gpg_private_key: ${{ secrets.BOT_GPG_SIGNING_KEY }} | ||
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }} | ||
fingerprint: "F0637CD9BCDAACC51D7976F3071E232FF33B2800" | ||
- name: Prepare git user for bot | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | ||
- name: Create new version | ||
run: | | ||
yarn config set version-git-tag true | ||
yarn version --patch | ||
- name: Execute building | ||
id: yarn-build | ||
run: yarn build | ||
git config --global user.name "arce-bot" | ||
git config --global user.email "[email protected]" | ||
git config --global user.signingkey $KEY_ID | ||
git config --global commit.gpgsign true | ||
env: | ||
KEY_ID: ${{ steps.bot-signing-key.outputs.keyid }} | ||
- name: Create prerelease version | ||
if: ${{ github.ref_name == 'beta' }} | ||
id: yarn-prerelease | ||
run: yarn version --prerelease --preid beta | ||
- name: Create patch version | ||
if: ${{ github.ref_name == 'main' }} | ||
id: yarn-patch | ||
run: yarn version --patch | ||
- name: Get version number | ||
id: vars | ||
run: | | ||
echo ::set-output name=version::$(sed -En "s/$VERSION_REGEX/\1/p" package.json) | ||
echo ::set-output name=git-tag::$(sed -En "s/$VERSION_REGEX/refs\/tags\/v\1/p" package.json) | ||
echo ::set-output name=release-filename::$(sed -En "s/$VERSION_REGEX/bits-cr-middy-joi-validator-v\1.tgz/p" package.json) | ||
echo ::set-output name=artifact-name::$(sed -En "s/$VERSION_REGEX/npm-package-v\1/p" package.json) | ||
env: | ||
VERSION_REGEX: .*"version".+"(([0-9]+\.[0-9]+\.[0-9]+)(-beta\.[0-9]+)*)".* | ||
- name: Generate package | ||
id: yarn-pack | ||
run: yarn pack --filename bits-cr-middy-joi-validator.tgz | ||
run: yarn pack | ||
- name: Upload package to artifacts | ||
id: upload-tgz-artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: bits-cr-middy-joi-validator.tgz | ||
path: bits-cr-middy-joi-validator.tgz | ||
- name: Publish to npmjs.org | ||
id: publish-to-npm | ||
run: yarn publish bits-cr-middy-joi-validator.tgz | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Setup github npm registry | ||
id: registry-npm-github | ||
uses: actions/setup-node@v3 | ||
with: | ||
registry-url: 'https://npm.pkg.github.com' | ||
- name: Publish to npm.pkg.github.com | ||
id: publish-to-npm-github | ||
run: yarn publish bits-cr-middy-joi-validator.tgz | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
name: ${{ steps.vars.outputs.artifact-name }} | ||
path: | | ||
${{ steps.vars.outputs.release-filename }} | ||
package.json | ||
if-no-files-found: error | ||
- name: Push changes and release tag | ||
id: git-push | ||
run: | | ||
git push origin | ||
git push origin --tags | ||
git push origin --tags | ||
- name: Create Github.com prerelease | ||
if: ${{ github.ref_name == 'beta' }} | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
prerelease: true | ||
name: ${{ steps.vars.outputs.version }} | ||
tag_name: ${{ steps.vars.outputs.git-tag }} | ||
files: | | ||
${{ steps.vars.outputs.release-filename }} | ||
- name: Create Github.com release | ||
if: ${{ github.ref_name == 'main' }} | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: ${{ steps.vars.outputs.version }} | ||
tag_name: ${{ steps.vars.outputs.git-tag }} | ||
files: | | ||
${{ steps.vars.outputs.release-filename }} | ||
- name: Create Github.com release | ||
if: ${{ github.ref_name == 'main' }} | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: ${{ steps.vars.outputs.version }} | ||
tag_name: ${{ steps.vars.outputs.git-tag }} | ||
files: | | ||
${{ steps.vars.outputs.release-filename }} | ||
publish-npmjs: | ||
name: Publish package to npmjs | ||
runs-on: ubuntu-latest | ||
needs: | ||
- package | ||
steps: | ||
- name: Setup npm and registry | ||
id: registry-npm-npmjs | ||
uses: actions/setup-node@v3 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Download package | ||
id: download | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ needs.package.outputs.artifact-name }} | ||
- name: Publish beta to npmjs.org | ||
if: ${{ github.ref_name == 'beta' }} | ||
id: publish-beta-to-npm | ||
run: yarn publish --tag beta ${{ steps.download.outputs.download-path }}/${{ needs.package.outputs.release-filename }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
- name: Publish to npmjs.org | ||
if: ${{ github.ref_name == 'main' }} | ||
id: publish-to-npm | ||
run: yarn publish ${{ steps.download.outputs.download-path }}/${{ needs.package.outputs.release-filename }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
publish-npmgithub: | ||
name: Publish package to npm.pkg.github.com | ||
runs-on: ubuntu-latest | ||
needs: | ||
- package | ||
steps: | ||
- name: Setup npm and registry | ||
id: registry-npm-github | ||
uses: actions/setup-node@v3 | ||
with: | ||
registry-url: "https://npm.pkg.github.com" | ||
- name: Download package | ||
id: download | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ needs.package.outputs.artifact-name }} | ||
- name: Publish beta to npm.pkg.github.com | ||
if: ${{ github.ref_name == 'beta' }} | ||
id: publish-beta-to-npm | ||
run: yarn publish --tag beta ${{ steps.download.outputs.download-path }}/${{ needs.package.outputs.release-filename }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish to npm.pkg.github.com | ||
if: ${{ github.ref_name == 'main' }} | ||
id: publish-to-npm | ||
run: yarn publish ${{ steps.download.outputs.download-path }}/${{ needs.package.outputs.release-filename }} | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters