Skip to content

Commit ebc4d15

Browse files
authored
Merge pull request #883 from Shopify/release-via-github-actions
Release via GitHub actions with changesets and provenance
2 parents 0c8c083 + 8dca04f commit ebc4d15

File tree

9 files changed

+3098
-2951
lines changed

9 files changed

+3098
-2951
lines changed

.changeset/config.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3+
"changelog": false,
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "restricted",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": []
11+
}

.github/workflows/npm-release.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release new NPM version
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: changeset-${{ github.head_ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
npm:
15+
name: Changeset release
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: write # to be able to publish a GitHub release
19+
pull-requests: write # to be able to comment on released pull requests
20+
id-token: write # to enable use of OIDC for npm provenance
21+
steps:
22+
- name: Checkout the repo
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 1
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 16.16
31+
cache: 'yarn'
32+
cache-dependency-path: '**/yarn.lock'
33+
34+
- name: Install dependencies
35+
run: yarn install --no-progress --ignore-engines
36+
37+
- name: Check for changesets
38+
id: check_changesets
39+
run: |
40+
if [ -z "$(ls -A .changeset)" ]; then
41+
echo "No changesets found. Exiting."
42+
echo "changesets_found=false" >> $GITHUB_ENV
43+
exit 0
44+
else
45+
echo "changesets_found=true" >> $GITHUB_ENV
46+
fi
47+
48+
- name: Update package version and remove changesets
49+
if: env.changesets_found == 'true'
50+
run: npx changeset version
51+
52+
- name: Commit and push changes
53+
if: env.changesets_found == 'true'
54+
run: |
55+
git config --global user.name 'github-actions[bot]'
56+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
57+
git add package.json .changeset
58+
git commit -m "Update package version & delete changesets"
59+
git push
60+
61+
- name: Publish to NPM
62+
if: env.changesets_found == 'true'
63+
id: changesets
64+
uses: changesets/action@v1
65+
with:
66+
publish: npx changeset publish
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
70+
NPM_CONFIG_PROVENANCE: true

.github/workflows/snapit.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Snapit with npm provenance
2+
3+
on:
4+
issue_comment:
5+
types:
6+
- created
7+
8+
jobs:
9+
snapit:
10+
name: Snapit
11+
if: ${{ github.event.issue.pull_request && github.event.comment.body == '/snapit' }}
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
id-token: write
17+
steps:
18+
- name: Checkout current branch
19+
uses: actions/checkout@v4
20+
21+
- name: Force snapshot
22+
run: |
23+
printf -- "---\n'@shopify/buy-button-js': patch\n" > snapshot.txt
24+
- name: Create snapshot version
25+
uses: Shopify/snapit@0c0d2dd62c9b0c94b7d03e1f54e72f18548e7752 # pin to a specific commit
26+
with:
27+
github_comment_included_packages: '@shopify/buy-button-js'
28+
build_script: 'yarn build'
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
32+
NPM_CONFIG_PROVENANCE: true

.gitignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ _site
1717
.sass-cache
1818
.jekyll-metadata
1919
/test/build
20-
config.json
20+
./config.json
2121
/.vscode
22-
.DS_Store
22+
.DS_Store

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"repository": "[email protected]:Shopify/buy-button-js.git",
1616
"publishConfig": {
1717
"access": "public",
18-
"@shopify:registry": "https://registry.npmjs.org/"
18+
"@shopify:registry": "https://registry.npmjs.org/",
19+
"provenance": true
1920
},
2021
"scripts": {
2122
"start": "rm -rf tmp && mkdir tmp && yarn run src:watch & yarn run styles:watch & yarn run serve",
@@ -68,6 +69,7 @@
6869
"@babel/plugin-transform-spread": "7.2.2",
6970
"@babel/plugin-transform-template-literals": "7.4.4",
7071
"@babel/plugin-transform-typeof-symbol": "7.2.0",
72+
"@changesets/cli": "^2.28.1",
7173
"@shopify/js-uploader": "https://github.com/Shopify/js-uploader.git",
7274
"aws-sdk": "2.6.8",
7375
"babelify": "10.0.0",

readme.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
[BuyButton.js on NPM](https://www.npmjs.com/package/@shopify/buy-button-js)
44

5-
BuyButton.js is a highly customizable UI library for adding ecommerce functionality to any website. It allows you to create interactive UI components such as product listings and shopping carts with minimal configuration, while allowing you to easily customize the appearance and behaviour of the components.
5+
BuyButton.js is a highly customizable UI library for adding e-commerce functionality to any website. It allows you to create interactive UI components such as product listings and shopping carts with minimal configuration, while allowing you to easily customize the appearance and behaviour of the components.
66
It uses the [JS Buy SDK](http://shopify.github.io/js-buy-sdk/) to connect to your Shopify store, giving you access to your products and collections.
77

88
To get started, take a look at [the documentation](http://shopify.github.io/buy-button-js/).
9-
For questions, suggestions and feeback, please <a href="https://github.com/Shopify/buy-button-js/issues">create an issue</a>.
9+
For questions, suggestions and feedback, please <a href="https://github.com/Shopify/buy-button-js/issues">create an issue</a>.
1010

1111
> [!NOTE]
1212
> The Buy Button JS library will soon be updated to use v3 of the JS Buy SDK library
@@ -18,8 +18,8 @@ yarn
1818
cp index.example.html index.html
1919
```
2020

21-
* Add your API key and shop domain to index.html
22-
* Set a product ID in index.html
21+
- Add your API key and shop domain to index.html
22+
- Set a product ID in index.html
2323

2424
```
2525
yarn run start
@@ -53,6 +53,7 @@ gem install jekyll
5353
```
5454
yarn run docs
5555
```
56-
Doc server will run at http://localhost:4000/buy-button-js/
56+
57+
Doc server will run at <http://localhost:4000/buy-button-js/>
5758
Docs source files are located in /docs.
5859
Docs are automatically deployed to gh-pages from main.

script/deploy.js

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
"use strict";
22

33
const Uploader = require('@shopify/js-uploader');
4-
const path = require('path');
5-
const fs = require('fs');
6-
const mime = require('mime-types');
74
const currentVersion = require('../package.json').version;
85
const awsConfig = require('../config.json').aws;
96
const awsSDK = require('aws-sdk');

shipit.production.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ dependencies:
55
deploy:
66
override:
77
- ejson decrypt -o config.json config.ejson
8-
- npm run deploy
9-
- npm publish
8+
- npm run deploy # upload built scripts to the CDN
9+
# - npm publish (npm publishing is now done via Github actions with changesets and provenance)

0 commit comments

Comments
 (0)