summaryrefslogtreecommitdiff
path: root/maint/release.in
blob: 40af317e9d9046f9534a7fc33c232e5cbb9b4477 (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/sh

ORIGIN_URL=$(shell git config --get remote.origin.url)
CURRENT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
PACKAGE='@PACKAGE@'
PACKAGE_VERSION='@PACKAGE_VERSION@'
abs_srcdir='@abs_srcdir@'
srcdir='@srcdir@'
abs_top_builddir='@abs_top_builddir@'
dist_man_MANS='lsrc.1 mkrc.1 rcdn.1 rcup.1 rcrc.5 rcm.7'

edit_package() {
  sed \
    -e "s|@PACKAGE[@]|$(PACKAGE)|g" \
    -e "s|@PACKAGE_VERSION[@]|$(PACKAGE_VERSION)|g" \
    -e "s|@DIST_ARCHIVES[@]|$(DIST_ARCHIVES)|g" \
    -e "s|@DIST_SHA[@]|$(DIST_SHA)|g"
}

# Tarball
release_build_tarball() {
  ([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \
    ([ -d gh-pages/dist ] || mkdir gh-pages/dist) && \
    cp $(DIST_ARCHIVES) gh-pages/dist && \
    cd gh-pages && \
      git add dist/$(DIST_ARCHIVES) && \
      git commit -m "Release version $(PACKAGE_VERSION) tarball"
}

release_push_tarball() {
  cd gh-pages && \
    git push
}

release_clean_tarball() {
  rm -rf gh-pages
  rm -rf $(DIST_ARCHIVES)
}

# Homebrew
release_build_homebrew() {
  ([ -d homebrew-formulae ] || git clone git@github.com:thoughtbot/homebrew-formulae.git homebrew-formulae) && \
    $(edit_package) homebrew/$(PACKAGE).rb.in > homebrew-formulae/Formula/$(PACKAGE).rb && \
    cd homebrew-formulae && \
    git add Formula/$(PACKAGE).rb && \
    git commit -m "$(PACKAGE): Release version $(PACKAGE_VERSION)"
}

release_push_homebrew() {
  cd homebrew-formulae && \
    git push
}

release_clean_homebrew() {
  rm -rf homebrew-formulae
  rm -rf $(DIST_ARCHIVES)
}

# Arch
release_build_arch() {
  ([ -d gh-pages ] || git clone --branch gh-pages . gh-pages) && \
    ([ -d gh-pages/arch ] || mkdir gh-pages/arch) && \
    $(edit_package) arch/PKGBUILD.in > gh-pages/arch/PKGBUILD &&\
    cd gh-pages &&\
      git add arch/PKGBUILD &&\
      git commit -m "Release version $(PACKAGE_VERSION) Arch package"
}

release_push_arch() {
  cd gh-pages && \
    git push
}

release_clean_arch() {
  rm -rf gh-pages
  rm -rf $(DIST_ARCHIVES)
}

# Deb
release_build_deb() {
  ([ -d deb-build ] || mkdir -p deb-build) && \
    cp $(DIST_ARCHIVES) deb-build/$(PACKAGE)_$(PACKAGE_VERSION).orig.tar.gz && \
    tar -C deb-build -xf deb-build/$(PACKAGE)_$(PACKAGE_VERSION).orig.tar.gz && \
    cp -R debian deb-build/$(PACKAGE)-$(PACKAGE_VERSION) && \
    cd deb-build/$(PACKAGE)-$(PACKAGE_VERSION) && \
    dch -d "New upstream release" && dch -r "" && \
    cp debian/changelog $(abs_srcdir)/debian/changelog && \
    debuild -us -uc && \
    cd $(abs_srcdir) && \
    ([ -d gh-pages ] || git clone --branch gh-pages $(ORIGIN_URL) gh-pages) && \
    ([ -d gh-pages/debs ] || mkdir gh-pages/debs) && \
    cp deb-build/$(PACKAGE)_$(PACKAGE_VERSION)*.deb gh-pages/debs && \
    cd gh-pages && \
    git add debs/$(PACKAGE)_$(PACKAGE_VERSION)*deb && \
    git commit -m "Release version $(PACKAGE_VERSION) for Debian" -- debs/$(PACKAGE)_$(PACKAGE_VERSION)*deb
}

release_push_deb() {
  cd gh-pages && \
    git push
}

release_clean_deb() {
  rm -rf gh-pages
  rm -rf deb-build
  rm -rf $(DIST_ARCHIVES)
}

# Tag
release_build_tag() {
  git tag -s v$(PACKAGE_VERSION) -m "Release $(PACKAGE_VERSION)"
}

release_push_tag() {
  git push origin --tags
}

release_clean_tag() {
}

generate_dist_sha() {
  export DIST_SHA=$(shasum $(srcdir)/$(DIST_ARCHIVES) | cut -d' ' -f1)
}

# manpages as HTML
release_build_man_html() {
  ([ -d $(abs_top_builddir)/gh-pages ] || git clone --branch gh-pages --single-branch .. $(abs_top_builddir)/gh-pages) && \
  for i in $(dist_man_MANS); do \
    mandoc -Thtml -Oman=%N.%S.html $$i > $(abs_top_builddir)/gh-pages/$$i.html ; \
  done && \
  cd $(abs_top_builddir)/gh-pages && \
  cp rcm.7.html index.html && \
  git add -A && \
  git commit -m "HTML documentation for $(PACKAGE_VERSION)"
}

release_push_man_html() {
  cd $(abs_top_builddir)/gh-pages && \
    git push -f $(ORIGIN_URL) gh-pages
}

release_clean_man_html() {
  rm -rf $(abs_top_builddir)/gh-pages
}

# Main:

if [ $# < 3 ]; then
  echo "Usage: release (build|push|clean) (tarball|homebrew|arch|deb|tag|man_html) DIST_ARCHIVES" >&2
  exit 64
fi

verb="$1"
noun="$2"
DIST_ARCHIVES="$3"
cmd="release_${verb}_${noun}"

${cmd}