Skip to content

Commit

Permalink
Add automatic publishing of tagged commits
Browse files Browse the repository at this point in the history
Publishes tagged commits to Github Releases/Luarocks via Travis CI. The deploy phase only exists for tags, and depends on the normal build/test phases completing successfully. Two environment variables are required to deploy:

- GITHUB_OAUTH_TOKEN: can be created via https://github.com/settings/tokens, only needs the public_repo scope (alternatively, can be set up via travis's CLI, see https://docs.travis-ci.com/user/deployment/releases/#authenticating-with-an-oauth-token)
- LUAROCKS_API_KEY: found at https://luarocks.org/settings/api-keys

Note: Committed .rockspecs changed to scm versions (using git as the source url)--versioned rockspecs (along with their .tar.gz) are generated by `.ci/make_rockspec.sh`

Addresses #275 (#275 (comment))
  • Loading branch information
squeek502 committed Aug 30, 2018
1 parent a95c6f3 commit 6b901a2
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 24 deletions.
25 changes: 25 additions & 0 deletions .ci/make_rockspec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh

version=$1
if [ -z "$version" ]; then
echo "must specify a version" >&2
exit 1
fi

# .rockspec
cp luv-scm-0.rockspec luv-${version}.rockspec
cp rockspecs/luv-scm-0.rockspec rockspecs/luv-${version}.rockspec
script="/^version/s@\"[^\"]\\+\"@\"${version}\"@"
sed -e "${script}" -i luv-${version}.rockspec
sed -e "${script}" -i rockspecs/luv-${version}.rockspec
script="s@git://github.com/luvit/luv.git@https://github.com/luvit/luv/releases/download/'..version..'/luv-'..version..'.tar.gz@"
sed -e "${script}" -i luv-${version}.rockspec
sed -e "${script}" -i rockspecs/luv-${version}.rockspec

# .tar.gz
rm -rf luv-${version}
mkdir -p luv-${version}/deps
cp -r src cmake CMakeLists.txt LICENSE.txt README.md docs.md luv-${version}/
cp -r deps/libuv deps/lua-compat-5.3 deps/*.cmake deps/lua_one.c luv-${version}/deps/
COPYFILE_DISABLE=true tar -czvf luv-${version}.tar.gz luv-${version}
rm -rf luv-${version}
22 changes: 21 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ os:
before_install:
- git submodule update --init --recursive
- git submodule update --recursive
- source .ci/setenv_lua.sh

script:
- if [ "x$PROCESS_CLEANUP_TEST" = "x" ]; then make && make test; else ./tests/test-sigchld-after-lua_close.sh; fi
# Test rock installation
- source .ci/setenv_lua.sh
- luarocks make
- test $PWD = `lua -e "print(require'luv'.cwd())"`
- luarocks remove luv
Expand All @@ -38,6 +38,26 @@ script:
- luarocks make rockspecs/$(ls rockspecs) LIBUV_DIR=build
- test $PWD = `lua -e "print(require'luv'.cwd())"`

jobs:
include:
- stage: deploy
if: tag IS present
env: WITH_LUA_ENGINE=LuaJIT LUA=luajit2.1
script: skip
before_deploy:
- .ci/make_rockspec.sh $TRAVIS_TAG
deploy:
provider: releases
api_key: $GITHUB_OAUTH_TOKEN
file: luv-$TRAVIS_TAG.tar.gz
overwrite: true
skip_cleanup: true
on:
tags: true
after_deploy:
- luarocks install lua-cjson # required for luarocks upload
- luarocks upload luv-$TRAVIS_TAG.rockspec --api-key=$LUAROCKS_API_KEY --force

notifications:
email: true
irc: "irc.freenode.org#luvit"
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ reset:
git checkout .

publish-luarocks:
rm -rf luv-${LUV_TAG}
mkdir -p luv-${LUV_TAG}/deps
cp -r src cmake CMakeLists.txt LICENSE.txt README.md docs.md luv-${LUV_TAG}/
cp -r deps/libuv deps/lua-compat-5.3 deps/*.cmake deps/lua_one.c luv-${LUV_TAG}/deps/
COPYFILE_DISABLE=true tar -czvf luv-${LUV_TAG}.tar.gz luv-${LUV_TAG}
github-release upload --user luvit --repo luv --tag ${LUV_TAG} \
--file luv-${LUV_TAG}.tar.gz --name luv-${LUV_TAG}.tar.gz
luarocks upload luv-${LUV_TAG}.rockspec --api-key=${LUAROCKS_TOKEN}
14 changes: 0 additions & 14 deletions bump.sh

This file was deleted.

4 changes: 2 additions & 2 deletions luv-1.22.0-1.rockspec → luv-scm-0.rockspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package = "luv"
version = "1.22.0-1"
version = "scm-0"
source = {
url = 'https://github.com/luvit/luv/releases/download/'..version..'/luv-'..version..'.tar.gz'
url = 'git://github.com/luvit/luv.git'
}

description = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- Alternate rockspec that uses luarocks builtin builder
package = "luv"
version = "1.22.0-1"
version = "scm-0"
source = {
url = 'https://github.com/luvit/luv/releases/download/'..version..'/luv-'..version..'.tar.gz'
url = 'git://github.com/luvit/luv.git'
}

description = {
Expand Down

0 comments on commit 6b901a2

Please sign in to comment.