Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat: add automatization to releases (#724)
Browse files Browse the repository at this point in the history
* feat: new release script

* feat: release canary version

* feat: run custom package build if there is a script for that
  • Loading branch information
patzick authored May 10, 2020
1 parent 3bc700a commit 0a2db60
Show file tree
Hide file tree
Showing 14 changed files with 336 additions and 42 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/deploy-storefrontcloud.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
name: Deploy to Storefrontcloud
on:
release:
types: [published]
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
env:
RELEASE_URL: https://shopware-pwa.storefrontcloud.io
INSTANCE_CODE: shopware-pwa
Expand All @@ -14,7 +15,7 @@ jobs:
run: |
mkdir test-project
cd ./test-project
npx @shopware-pwa/cli@canary init --u ${{ secrets.SHOPWARE_ADMIN_USER }} --p ${{ secrets.SHOPWARE_ADMIN_PASSWORD }} --ci --devMode
npx @shopware-pwa/cli init --u ${{ secrets.SHOPWARE_ADMIN_USER }} --p ${{ secrets.SHOPWARE_ADMIN_PASSWORD }} --ci --devMode
yarn build
- name: Build and publish docker image
uses: elgohr/Publish-Docker-Github-Action@master
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/publish-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,15 @@ jobs:
with:
node-version: "12.x"
registry-url: https://registry.npmjs.org/
- name: Build packages
run: |
yarn --frozen-lockfile
yarn build --release
cd ./packages/cli && yarn build && cd ../../
- name: Publish canary version
run: |
yarn lerna publish --canary --force-publish --yes --preid prealpha --dist-tag canary
yarn --frozen-lockfile
yarn release --canary
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
build:
runs-on: ubuntu-latest
needs: publish
steps:
- name: Create default-theme project
run: |
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/release-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10

env:
REPO_URL: https://github.com/DivanteLtd/shopware-pwa

name: Create Release

jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release for Tag
id: release_tag
uses: yyx990803/release-tag@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
body: |
Please refer to [CHANGELOG.md](${{ env.REPO_URL }}/blob/master/CHANGELOG.md) for details.
13 changes: 6 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
const lernaJson = require("./lerna.json");
const e2e = require("minimist")(process.argv.slice(2))["e2e"];

const isUnitTest = e2e !== "true";

console.log(`Starting ${isUnitTest ? "unit" : "e2e"} tests...`);

const UNIT_TEST_PATTERNS = [
"<rootDir>/packages/**/__tests__/**/*spec.[jt]s?(x)"
"<rootDir>/packages/**/__tests__/**/*spec.[jt]s?(x)",
];
const E2E_TEST_PATTERNS = ["<rootDir>/packages/**/__e2e__/**/*spec.[jt]s?(x)"];
module.exports = {
preset: "ts-jest",
globals: {
__DEV__: true,
__TEST__: true,
__VERSION__: require("./packages/nuxt-module/package.json").version,
__VERSION__: require("./package.json").version,
__BROWSER__: false,
__BUNDLER__: true,
__RUNTIME_COMPILE__: true,
__GLOBAL__: false,
__NODE_JS__: true,
__FEATURE_OPTIONS__: true,
__FEATURE_SUSPENSE__: true
__FEATURE_SUSPENSE__: true,
},
collectCoverage: isUnitTest,
coverageDirectory: "coverage",
Expand All @@ -31,7 +30,7 @@ module.exports = {
"!packages/*/src/**/*.d.ts",
"!packages/default-template/**",
"!packages/cli/**",
"!**/interfaces/**"
"!**/interfaces/**",
],
watchPathIgnorePatterns: ["/node_modules/", "/dist/", "/.git/"],
modulePathIgnorePatterns: [".yalc"],
Expand All @@ -40,8 +39,8 @@ module.exports = {
"^@shopware-pwa/commons/(.*?)$": "<rootDir>/packages/commons/$1",
"^@shopware-pwa/(.*?)/src$": "<rootDir>/packages/$1/src",
"^@shopware-pwa/(.*?)/src/(.*?)$": "<rootDir>/packages/$1/src/$2",
"^@shopware-pwa/(.*?)$": "<rootDir>/packages/$1/src"
"^@shopware-pwa/(.*?)$": "<rootDir>/packages/$1/src",
},
rootDir: __dirname,
testMatch: isUnitTest ? UNIT_TEST_PATTERNS : E2E_TEST_PATTERNS
testMatch: isUnitTest ? UNIT_TEST_PATTERNS : E2E_TEST_PATTERNS,
};
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "shopware-pwa",
"version": "0.1.0-alpha.5",
"private": true,
"workspaces": {
"packages": [
Expand All @@ -25,7 +26,9 @@
"test:cypress": "cypress run",
"test:coverage": "yarn test --coverage",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
"docs:build": "vuepress build docs",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"release": "node scripts/release.js"
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -60,6 +63,7 @@
"conventional-changelog-cli": "^2.0.31",
"coveralls": "^3.0.13",
"cypress": "^4.4.1",
"enquirer": "^2.3.5",
"execa": "^4.0.0",
"faker": "^4.1.0",
"fs-extra": "^9.0.0",
Expand All @@ -75,6 +79,7 @@
"rollup-plugin-peer-deps-external": "^2.2.2",
"rollup-plugin-terser": "^5.3.0",
"rollup-plugin-typescript2": "^0.27.0",
"semver": "^7.3.2",
"ts-jest": "^25.4.0",
"tslib": "^1.11.1",
"typedoc": "^0.17.4",
Expand Down
6 changes: 2 additions & 4 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
"compile": "tsc -p .",
"copy-templates": "if [ -e ./src/templates ]; then cp -a ./src/templates ./build/; fi",
"build": "yarn format && yarn lint && yarn clean-build && yarn compile && yarn copy-templates",
"prepublishOnly": "yarn build",
"test": "jest",
"watch": "jest --watch",
"snapupdate": "jest --updateSnapshot",
"coverage": "jest --coverage",
"snyk-protect": "snyk protect",
"prepublish": "npm run snyk-protect"
"snyk-protect": "snyk protect"
},
"files": [
"tsconfig.json",
Expand All @@ -32,7 +30,7 @@
],
"license": "MIT",
"dependencies": {
"gluegun": "^4.2.0",
"gluegun": "^4.3.1",
"lodash": "^4.17.15",
"request": "^2.88.2",
"snyk": "^1.316.1",
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/types.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
// export types

export interface ShopwarePwaToolbox {
isProduction: boolean;
}
3 changes: 1 addition & 2 deletions packages/default-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"scripts": {
"lint": "prettier --write './**/*.{js,vue}'",
"test": "jest",
"snyk-protect": "snyk protect",
"prepublish": "npm run snyk-protect"
"snyk-protect": "snyk protect"
},
"husky": {
"hooks": {
Expand Down
3 changes: 1 addition & 2 deletions packages/nuxt-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
"access": "public"
},
"scripts": {
"snyk-protect": "snyk protect",
"prepublish": "npm run snyk-protect"
"snyk-protect": "snyk protect"
},
"snyk": true
}
8 changes: 4 additions & 4 deletions scripts/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
const args = require("minimist")(process.argv.slice(2));
const fs = require("fs");
const path = require("path");
const baseVersion = require("../lerna.json").version;
const baseVersion = require("../package.json").version;

const packagesDir = path.resolve(__dirname, "../packages");
const files = fs.readdirSync(packagesDir);

files.forEach(shortName => {
files.forEach((shortName) => {
if (!fs.statSync(path.join(packagesDir, shortName)).isDirectory()) {
return;
}
Expand Down Expand Up @@ -36,9 +36,9 @@ files.forEach(shortName => {
sideEffects: false,
repository: {
type: "git",
url: "git+https://github.com/DivanteLtd/shopware-pwa"
url: "git+https://github.com/DivanteLtd/shopware-pwa",
},
license: "MIT"
license: "MIT",
};
fs.writeFileSync(pkgPath, JSON.stringify(json, null, 2));
}
Expand Down
6 changes: 6 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ async function build(target) {
return;
}

// run custom package build if there is one
if (pkg.scripts && pkg.scripts.build) {
await execa("yarn", ["build"], { stdio: "inherit", cwd: pkgDir });
return;
}

// if building a specific format, do not remove dist.
if (!formats) {
await fs.remove(`${pkgDir}/dist`);
Expand Down
Loading

1 comment on commit 0a2db60

@vercel
Copy link

@vercel vercel bot commented on 0a2db60 May 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.