使用 travis 将版本发布到 gh-pages 而不删除以前的版本
Publish releases to gh-pages with travis without deleting previous releases
我想发布版本到 gh-pages。可以将部署提供程序配置为使用 keep-history: true
保留历史记录。但是,我希望以前的版本不仅在 git 历史记录中可用,而且不希望从存储库中删除。
我已经配置 yarn 和 webpack 为每个标签创建一个单独的目录,并将分发放在 "latest" 目录和这个标签特定目录中。我希望看到所有以前版本的标签目录,而不仅仅是最新版本。
以下是我当前配置的结果:https://github.com/retog/rdfgraphnode-rdfext/tree/gh-pages
我找到了以下解决方案。
在travis.yml
中替换:
- provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
keep-history: true
local-dir: distribution
on:
tags: true
与:
- provider: script
script: bash .travis_publish
on:
tags: true
并添加脚本文件.travis_publish
,内容如下:
#!/bin/bash
PUBLICATION_BRANCH=gh-pages
# Checkout the branch
REPO_PATH=$PWD
pushd $HOME
git clone --branch=$PUBLICATION_BRANCH https://${GITHUB_TOKEN}@github.com/$TRAVIS_REPO_SLUG publish 2>&1 > /dev/null
cd publish
# Update pages
cp -r $REPO_PATH/distribution .
# Commit and push latest version
git add .
git config user.name "Travis"
git config user.email "travis@travis-ci.org"
git commit -m "Updated distribution."
git push -fq origin $PUBLICATION_BRANCH 2>&1 > /dev/null
popd
我想发布版本到 gh-pages。可以将部署提供程序配置为使用 keep-history: true
保留历史记录。但是,我希望以前的版本不仅在 git 历史记录中可用,而且不希望从存储库中删除。
我已经配置 yarn 和 webpack 为每个标签创建一个单独的目录,并将分发放在 "latest" 目录和这个标签特定目录中。我希望看到所有以前版本的标签目录,而不仅仅是最新版本。
以下是我当前配置的结果:https://github.com/retog/rdfgraphnode-rdfext/tree/gh-pages
我找到了以下解决方案。
在travis.yml
中替换:
- provider: pages
skip-cleanup: true
github-token: $GITHUB_TOKEN
keep-history: true
local-dir: distribution
on:
tags: true
与:
- provider: script
script: bash .travis_publish
on:
tags: true
并添加脚本文件.travis_publish
,内容如下:
#!/bin/bash
PUBLICATION_BRANCH=gh-pages
# Checkout the branch
REPO_PATH=$PWD
pushd $HOME
git clone --branch=$PUBLICATION_BRANCH https://${GITHUB_TOKEN}@github.com/$TRAVIS_REPO_SLUG publish 2>&1 > /dev/null
cd publish
# Update pages
cp -r $REPO_PATH/distribution .
# Commit and push latest version
git add .
git config user.name "Travis"
git config user.email "travis@travis-ci.org"
git commit -m "Updated distribution."
git push -fq origin $PUBLICATION_BRANCH 2>&1 > /dev/null
popd