This repository was archived by the owner on Sep 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·72 lines (55 loc) · 2.29 KB
/
Copy pathpublish.sh
File metadata and controls
executable file
·72 lines (55 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
set -e
# This script runs on every push to master of the toolkit. It downloads a tarball
# of the toolkit from GitHub.
# Make sure we're building the right thing in Travis
git checkout master
git reset --hard origin/master
wget https://github.com/alphagov/govuk_frontend_toolkit/archive/master.tar.gz -O new-toolkit.tar.gz
tar -xzf new-toolkit.tar.gz
cd govuk_frontend_toolkit-master/
# Remove the package.json (with -f so that we don't fail if it doesn't exist)
rm -f package.json
# Toolkit development happens in a separate repository, so remove dev and docs-related things
rm -f README.md
rm -rf docs
rm -rf spec
rm -f CONTRIBUTING.md
rm -f Gruntfile.js
rm -f Gemfile
rm -f Gemfile.lock
rm -f push.sh
rm -f trigger.sh
rm -f create-release.sh
# Move the actual toolkit files into the repo where this script is
# --delete: delete extraneous files from dest dir
# --archive: preserves permissions, times, symbolic links, etc
# Note: src of `*` is different from `.`, especially for delete!
# - `*` expands to each file/dir in src, which are rsync'd individually. A file that exists in dest
# but not src won't be deleted. This is the behaviour we want.
# - `.` copies the directory in one go, deleting ANY files in dest that are not in src, which will
# delete key files in this repo - like `package.json`, even `.git/`
rsync --delete --archive * ..
cd ..
rm -r govuk_frontend_toolkit-master
rm new-toolkit.tar.gz
echo "Check to see if the version file has been updated"
# get the version from the version file
VERSION_LATEST=`cat VERSION.txt`
echo "Version in VERSION.txt: $VERSION_LATEST"
# get the version from npm
VERSION_REGISTRY=`npm view govuk_frontend_toolkit version`
echo "Version of npm package: $VERSION_REGISTRY"
if [ "$VERSION_LATEST" != "$VERSION_REGISTRY" ]; then
# Update `package.json` version field, without creating it's own commit or tag
# https://docs.npmjs.com/cli/version
npm version -f --no-git-tag-version $VERSION_LATEST
# Adds, modifies, and removes index entries to match the working tree.
# https://git-scm.com/docs/git-add#git-add--A
git add --all
git commit -m "Bump npm version of govuk_frontend_toolkit to $VERSION_LATEST"
git push origin_ssh master
else
echo 'VERSION.txt is the same as the version available on the registry'
echo 'Not publishing anything'
fi