-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathzanata-0install-release
executable file
·132 lines (114 loc) · 4.14 KB
/
zanata-0install-release
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash -eu
### NAME
### zanata-0install-release - release package via 0install
###
### SYNOPSIS
### zanata-0install-release <package> <version>
###
###
### ARGUMENTS
### <package>
### The package to be released, so far we have "zanata-cli"
###
### <version>
### The version of package to be release.
### e.g. 4.4.0, 4.4.0-alpha-3, 4.5.0-rc-2
###
###
### DESCRIPTION
### zanata-0install-release releases package via 0install.
###
### This script should works in Jenkins or as a standalone command.
### However, this script assumes that feed and template files (such
### as zanata-cli.xml and zanata-cli.xml.template) are in current
### directory.
###
### It also assumes the version to be released are already in maven central.
###
### This script automatically installs the missing 0install tool scripts
### such as 0template and 0repo in $HOME/bin
###
### ENVIRONMENT
### GPG_SIGNING_KEY
### (Required) The GPG Key used to sign the feed.
###
### STABILITY
### The stability of this release.
### Valid values: Auto, stable, testing, developer, buggy, insecure
### Auto means it will give Stable to official release, and Testing for
### pre-release like rc (rc) or alpha (pre).
### Default: Auto
: ${STABILITY:=Auto}
###
### BRANCH
### (Experimental) the script branch to be used.
### If you want to try something new in a pull request,
### you can specify the pull request branch.
### Default: master
: ${BRANCH:=master}
HOME_BIN_DIR=$HOME/bin
FEED_UPLOAD_DIR=$(pwd)
export ZANATA_REMOTE_PROGRAM=zanata-0install-release
export ZANATA_SCRIPTS_BRANCH=$BRANCH
source <(curl -q https://raw.githubusercontent.com/zanata/zanata-scripts/$BRANCH/zanata-functions)
install_zero_program(){
local prog=$1
local url=$2
[[ -r $HOME_BIN_DIR/$prog ]] || 0install add $prog $url
}
create_feed(){
local feedPrefix=$1
local templateFile=$2
local feedFile=$feedPrefix-$version.xml
if [[ ! -e $feedFile ]]; then
echo_stderr "Creating $feedFile from $templateFile - version $version"
$HOME_BIN_DIR/0template $templateFile version=$version stability=$Stability "dist_url=$DistUrl"
fi
}
publish_interface(){
local interface=$1
set -x
yes | $HOME_BIN_DIR/0publish --add-version=$version --archive-extract=$Package-$ArtifactVersion --archive-url=$DistUrl --archive-file=/tmp/$PackageFilename "--key=$GPG_SIGNING_KEY" --xmlsign --set-released=today --set-stability=$Stability --set-main=bin/zanata-cli $interface.xml
set +x
}
[[ -z ${GPG_SIGNING_KEY-} ]] && echo_stderr "Environment GPG_SIGNING_KEY is needed" && exit $EXIT_FATAL_INVALID_OPTIONS
if [[ $# -lt 2 ]]; then
sed -rn -e '/^###/ s/^###( )?//p' $0
exit $EXIT_FATAL_INVALID_ARUGMENTS
fi
Package=$1
ArtifactVersion=$2
if [[ $ArtifactVersion = auto ]];then
ArtifactVersion=$(detect_remote_repo_latest_version https://github.com/zanata/zanata-platform 'platform-*')
fi
## 0install accept rcX but not rc-X
version=$(sed -e 's/alpha-/pre/' <<<$(sed -e 's/rc-/rc/' <<<$ArtifactVersion))
if [[ $STABILITY = Auto ]];then
case $ArtifactVersion in
*-rc-* | *-alpha-* )
Stability=testing
;;
* )
Stability=stable
;;
esac
else
Stability=$STABILITY
fi
DistUrlPrefix="https://repo1.maven.org/maven2/org/zanata/$Package"
PackageFilename="$Package-$ArtifactVersion-dist.zip"
DistUrl="$DistUrlPrefix/$ArtifactVersion/$PackageFilename"
InterfaceUrlPrefix="https://raw.githubusercontent.com/zanata/zanata.github.io/master/files/0install"
## Install 0install tools
mkdir -p $HOME_BIN_DIR
install_zero_program 0template http://0install.net/tools/0template.xml
install_zero_program 0publish http://0install.net/2006/interfaces/0publish
## Download
curl -L -o /tmp/$PackageFilename $DistUrl
cd files/0install
#create_feed zanata-cli zanata-cli.xml.template
#create_feed zanata-cli-jre zanata-cli-jre.xml.template
publish_interface ${Package}
publish_interface ${Package}-jre
git add *.gpg catalog.xml "${Package}.xml" "${Package}-jre.xml"
git commit -m "update(0install) $Package-$version"