Skip to content

Commit c04a05e

Browse files
author
Kaspars Dambis
authored
Store build releases in a distribution repository (xwp#1074)
1 parent f939e46 commit c04a05e

File tree

6 files changed

+62
-3
lines changed

6 files changed

+62
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/node_modules/
44
/vendor/
55
/build/
6+
/dist/
67
/.vagrant/
78
/console.log
89
/phpcs.xml

.travis.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ jobs:
2020
env:
2121
WORDPRESS_IMAGE_VERSION: php7.2
2222

23+
- name: Test Release Bundle
24+
script: npm run release
25+
2326
- stage: deploy
2427
name: Tag Release
2528
if: tag IS present
26-
before_deploy:
27-
- npm run release
29+
script: npm run release
2830
deploy:
2931
provider: releases
3032
api_key:
@@ -34,6 +36,23 @@ jobs:
3436
file:
3537
- stream.zip
3638
- stream-$TRAVIS_TAG.zip
39+
on:
40+
all_branches: true
41+
repo: xwp/stream
42+
43+
- name: Tag Package
44+
if: branch IS present AND type = push
45+
script: npm run release
46+
before_deploy:
47+
- openssl aes-256-cbc -K $encrypted_49634e5b1863_key -iv $encrypted_49634e5b1863_iv -in ./local/travis/travis_deploy_key.enc -out ~/.ssh/id_rsa -d
48+
- chmod 600 ~/.ssh/id_rsa
49+
deploy:
50+
provider: script
51+
script: ./local/scripts/dist.sh
52+
skip_cleanup: true
53+
on:
54+
all_branches: true
55+
repo: xwp/stream
3756

3857
services:
3958
- docker

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ module.exports = function( grunt ) {
6565
'languages/*',
6666
'readme.txt',
6767
'readme.md',
68+
'composer.json',
6869
'contributing.md',
6970
],
7071
dest: 'build',

local/scripts/dist.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env bash
2+
3+
# Set this to -ex for verbose output.
4+
set -ex
5+
6+
ROOT_DIR="$(git rev-parse --show-toplevel)"
7+
WORKING_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
8+
COMMIT_MESSAGE="$(git log -1 --oneline)"
9+
SRC_DIR="$ROOT_DIR/build"
10+
11+
DIST_REPO="[email protected]:xwp/stream-dist.git"
12+
DIST_DIR="$ROOT_DIR/dist"
13+
DIST_BRANCH="${TRAVIS_BRANCH:-$WORKING_BRANCH}"
14+
DIST_TAG="${1:-$TRAVIS_TAG}"
15+
16+
export GIT_DIR="$DIST_DIR/.git"
17+
export GIT_WORK_TREE="$DIST_DIR"
18+
19+
# Start with a clean slate.
20+
rm -rf "$DIST_DIR"
21+
22+
git clone --progress --verbose "$DIST_REPO" "$DIST_DIR/.git"
23+
git checkout -B "$DIST_BRANCH"
24+
25+
# Use the release bundle as the work tree.
26+
export GIT_WORK_TREE="$SRC_DIR"
27+
28+
# Commit the latest changes.
29+
git add --all
30+
git commit --allow-empty --message "$COMMIT_MESSAGE"
31+
32+
# And maybe tag a release.
33+
if [ -n "$DIST_TAG" ]; then
34+
echo "Tagging a release: $DIST_TAG"
35+
git tag --force "$DIST_TAG"
36+
fi
37+
38+
git push --force --set-upstream origin "$DIST_BRANCH" --tags

local/travis/travis_deploy_key.enc

1.64 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838
"scripts": {
3939
"postinstall": "composer install && npm run build",
40-
"build": "grunt default",
40+
"build": "grunt build",
4141
"release": "grunt release",
4242
"deploy": "grunt deploy",
4343
"lint-js": "eslint .",

0 commit comments

Comments
 (0)