Skip to content

Commit d2b4f25

Browse files
committed
crystal: Add make release support to Crystal
Combine and DRY with release process for Go. Both need to publish releases to another repo.
1 parent a379989 commit d2b4f25

File tree

6 files changed

+97
-52
lines changed

6 files changed

+97
-52
lines changed

crystal/LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

crystal/Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ endif
88

99
BASE := $(ROOT)/crystal
1010

11-
VERSION := $(shell grep 'VERSION =' src/yamlscript/version.cr | cut -d'"' -f2)
12-
YAMLSCRIPT_VERSION ?= 0.1.95
1311
LIBYS_SO_PATH := $(ROOT)/libyamlscript/lib/$(LIBYS_SO_FQNP)
1412
BUILD_DEPS := $(LIBYS_SO_PATH)
1513

@@ -20,10 +18,10 @@ build:: build-doc
2018
build-doc:: ReadMe.md
2119

2220
ifdef CRYSTAL
23-
test:: run-example test-crystal test-ffi
21+
test:: test-example test-crystal test-ffi
2422
endif
2523

26-
run-example: $(BUILD_DEPS)
24+
test-example: $(BUILD_DEPS)
2725
$(CRYSTAL) run examples/simple.cr
2826

2927
test-crystal: $(BUILD_DEPS)
@@ -32,10 +30,11 @@ test-crystal: $(BUILD_DEPS)
3230
test-ffi: $(BUILD_DEPS)
3331
$(CRYSTAL) run test/ffi.cr
3432

33+
release:
34+
$(ROOT)/util/release-crystal
35+
3536
clean::
3637
$(RM) -r lib bin .crystal .shards shard.lock libyamlscript.so
3738

3839
$(LIBYS_SO_PATH):
3940
$(MAKE) -C $(ROOT)/libyamlscript $(LIBYS_SO_FQNP)
40-
41-
.PHONY: test

util/release-crystal

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
3+
lang=crystal
4+
5+
source "${YAMLSCRIPT_ROOT?}/util/release-repo.bash"
6+
7+
update() (
8+
(
9+
cd "$repo_dir" || exit
10+
rm -fr \
11+
examples \
12+
spec \
13+
src \
14+
test
15+
)
16+
17+
cp "$root/License" "$repo_dir/LICENSE"
18+
19+
(
20+
cd "$from_dir" || exit
21+
cp ReadMe.md \
22+
shard.yml \
23+
"$repo_dir/"
24+
cp -r \
25+
examples \
26+
spec \
27+
src \
28+
test \
29+
"$repo_dir/"
30+
)
31+
)
32+
33+
main "$@"

util/release-go

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,24 @@
11
#!/usr/bin/env bash
22

3-
set -euo pipefail
3+
lang=go
44

5-
set -x
5+
source "${YAMLSCRIPT_ROOT?}/util/release-repo.bash"
66

7-
cd "$YAMLSCRIPT_ROOT"
7+
update() (
8+
cp "$root/License" "$repo_dir/LICENSE"
89

9-
ys_go_root=.git/tmp/yamlscript-go
10-
[email protected]:yaml/yamlscript-go
10+
(
11+
cd "$from_dir" || exit
12+
cp \
13+
ReadMe.md \
14+
go.mod \
15+
go.sum \
16+
yamlscript.go \
17+
"$repo_dir"
18+
)
1119

12-
rm -fr $ys_go_root
13-
git clone $ys_go_url $ys_go_root
14-
15-
cp \
16-
go/ReadMe.md \
17-
go/go.mod \
18-
go/go.sum \
19-
go/yamlscript.go \
20-
$ys_go_root
21-
22-
perl -pi -e 's{yamlscript/go}{yamlscript-go}' \
23-
$ys_go_root/go.mod
24-
25-
(
26-
cd $ys_go_root || exit
27-
git commit -a -m "Release $YS_RELEASE_VERSION_NEW"
28-
git push
29-
git tag "v$YS_RELEASE_VERSION_NEW"
30-
git push --tags
20+
perl -pi -e 's{yamlscript/go}{yamlscript-go}' \
21+
"$repo_dir/go.mod"
3122
)
23+
24+
main "$@"

util/release-repo.bash

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# shellcheck disable=2034,2154
2+
3+
set -euo pipefail
4+
5+
set -x
6+
7+
root=$YAMLSCRIPT_ROOT
8+
version=$YS_RELEASE_VERSION_NEW
9+
10+
main() (
11+
init
12+
clone
13+
update
14+
release
15+
)
16+
17+
init() {
18+
repo_dir=$root/.git/tmp/yamlscript-$lang
19+
[email protected]:yaml/yamlscript-$lang
20+
from_dir=$root/$lang
21+
}
22+
23+
[email protected]:yaml/yamlscript-$lang
24+
from_dir=$root/$lang
25+
26+
clone() (
27+
rm -fr "$repo_dir"
28+
git clone "$repo_url" "$repo_dir"
29+
)
30+
31+
release() (
32+
cd "$repo_dir" || exit
33+
git add -A .
34+
git commit -m "Release $YS_RELEASE_VERSION_NEW"
35+
# git push
36+
git tag "v$YS_RELEASE_VERSION_NEW"
37+
# git push --tags
38+
)
39+
40+
true

util/release-yamlscript

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ steps =: 11
1919
bindings =::
2020
- java
2121
- clojure
22+
- crystal
2223
- go
2324
- julia
2425
- nodejs
@@ -237,7 +238,7 @@ defn step-10(ctx):
237238
try:
238239
run: "make -C $dir release"
239240
catch Exception e:
240-
if (dir == 'clojure') || (dir == 'java'):
241+
if dir.in?(qw(clojure java)):
241242
warn: "Failed to release $dir. Continuing."
242243
die: "Failed to release $dir. Exiting."
243244

0 commit comments

Comments
 (0)