Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix publishing configuration, closes #858 #863

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
name: Publish Release

on:
pull_request:
types: [closed]
push:
branches: [main]

jobs:
publish-release:
permissions:
contents: write
if: |
github.event.pull_request.merged == true &&
startsWith(github.event.pull_request.head.ref, 'release/')
# release merge commits come from GitHub user
if: github.event.head_commit.committer.name == 'GitHub'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.sha }}
# we need this commit + the last so we can compare below
fetch-depth: 2
# exit early if the version has not changed
- run: ./scripts/check-version.sh ${{ github.event.before }}
- name: Get Node.js version
id: nvm
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
- uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- uses: MetaMask/action-publish-release@v1
- uses: MetaMask/action-publish-release@v2.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: |
Expand Down Expand Up @@ -51,6 +54,8 @@ jobs:
- name: Dry Run Publish
# omit npm-token token to perform dry run publish
uses: MetaMask/action-npm-publish@v1.1.0
env:
SKIP_PREPACK: true

publish-npm:
environment: npm-publish
Expand All @@ -71,3 +76,5 @@ jobs:
uses: MetaMask/action-npm-publish@v1.1.0
with:
npm-token: ${{ secrets.NPM_TOKEN }}
env:
SKIP_PREPACK: true
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!CHANGELOG.md' '**/*.yml' '!.yarnrc.yml' --ignore-path .gitignore",
"prepack": "yarn build",
"prepack": "./scripts/prepack.sh",
"setup": "yarn install",
"test": "jest",
"test:watch": "jest --watch"
Expand Down
19 changes: 19 additions & 0 deletions scripts/check-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

set -x
set -e
set -o pipefail

BEFORE="${1}"

if [[ -z $BEFORE ]]; then
echo "Error: Before SHA not specified."
exit 1
fi

VERSION_BEFORE="$(git show "$BEFORE":package.json | jq --raw-output .version)"
VERSION_AFTER="$(jq --raw-output .version package.json)"
if [[ "$VERSION_BEFORE" == "$VERSION_AFTER" ]]; then
echo "Notice: version unchanged. Skipping release."
exit 1
fi
12 changes: 12 additions & 0 deletions scripts/prepack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -x
set -e
set -o pipefail

if [[ -n $SKIP_PREPACK ]]; then
echo "Notice: skipping prepack."
exit 0
fi

yarn build