Travis CI:将JAR部署到Github版本

时间:2018-08-08 07:51:49

标签: travis-ci github-release

提交主文档后,我想使用Travis在Github Releases中创建漂亮的帖子

这就是我需要的:

  • 建立自定义标题
  • 建立自定义描述
  • 仅发布没有源代码zip的版本

我尽力了,但是我只能将二进制文件添加到发行版中。这是我的配置:

language: java
sudo: false
install: gradle wrapper --gradle-version 4.2
jdk:
- oraclejdk8
script:
- chmod +x gradlew
- "./gradlew test"
- "./gradlew build"
- "./gradlew jar"
- cd build # test
- ls
- cd libs
- ls
- pwd
- echo $TRAVIS_BUILD_NUMBER
cache:
  directories:
  - "$HOME/.gradle"
  - ".gradle"
before_deploy:
  # Set up git user name and tag this commit
  - git config --local user.name "RareScrap"
  - git config --local user.email "RareScrap@users.noreply.github.com"
  - export GIT_TAG=$TRAVIS_BRANCH-v0.1.$TRAVIS_BUILD_NUMBER
  - git tag $GIT_TAG -a -m "Generated tag from TravisCI for build $TRAVIS_BUILD_NUMBER"

deploy:
  provider: releases
  api_key:
    secure: [redacted]
  file: "/home/travis/build/RareScrap/travis.test/build/libs/*"
  skip_cleanup: true
  file_glob: true
  on:
    repo: RareScrap/travis.test
    branches:    # ← new! ghjgjghjghjghj
          only:      # ← new!
            - master # ← new!

1 个答案:

答案 0 :(得分:2)

GitHub Releases API可以接受:

  • [String]名称-版本名称
  • [String]正文-发行说明的内容
  • [Boolean]草稿-将此版本标记为草稿
  • [Boolean]预发行版-将此发行版标记为预发行版

Source

仅在master上使用on而不是only

因此,只需添加更改您的部署即可:

deploy:
  provider: releases
  api_key:
    secure: [redacted]
  file: "/home/travis/build/RareScrap/travis.test/build/libs/*"
  skip_cleanup: true
  file_glob: true
  on:
    repo: RareScrap/travis.test
    branches:    # ← new! ghjgjghjghjghj
          only:      # ← new!
            - master # ← new!

对此:

deploy:
  provider: releases
  api_key:
    secure: [redacted]
  file: "/home/travis/build/RareScrap/travis.test/build/libs/*"
  skip_cleanup: true
  file_glob: true
  on:
    repo: RareScrap/travis.test
    branch: master
  name: $YOUR_RELEASE_NAME
  body: $YOUR_RELEASE_CONTENT

在我做过非常相似的事情时,请随时参考my .travis.yml file

希望这会有所帮助!