egg*_*ert 31 github github-api
我有一个私有github仓库中的应用程序,我想知道这些版本是否可以公开,以便应用程序可以从github自动更新自己,而不是我们必须托管它.
另外,我想知道是否可以使用已部署的应用程序中的github api来检查新的更新.
Von*_*onC 26
解决方法是创建一个公共仓库,包括:
git commit --allow-empty
)这样,您就有了一个专门用于发布托管的可见仓库,以及一个用于源开发的私有回购.
kyr*_*yr0 18
2022 年这个问题的答案更加直接。您只需要使用预装的gh
CLI:
gh release create v0.0.1 foobar.zip -R https://github.com/your/repo-here
Run Code Online (Sandbox Code Playgroud)
foobar.zip
此命令将创建一个标签 v0.0.1 和一个带有公共存储库上附加的本地文件的版本。您可以在任何私有存储库的 GitHub Action 中运行它。
该-R
参数指向您要在其上创建标签/版本的存储库。foobar.zip
将位于您的本地目录中。
这里有一件事很重要:GITHUB_TOKEN
仍然必须设置为您想要发布的存储库的令牌!
完整示例:
gh release create v0.0.1 foobar.zip -R https://github.com/your/repo-here
Run Code Online (Sandbox Code Playgroud)
如果您计划重新发布并覆盖现有版本,也可以gh release delete
。该-d
标志将发布作为草稿等创建。请查看文档。
我通过设置使用稍微更高级的方法:
- name: Publish
env:
GITHUB_TOKEN: "${{ secrets.RELEASE_REPO_SECRET }}"
run: |
gh release create v0.0.1 foobar.zip -R https://github.com/your/repo-here
Run Code Online (Sandbox Code Playgroud)
并在文件中scripts/publish.sh
:
shell: bash
run: $GITHUB_ACTION_PATH/scripts/publish.sh
Run Code Online (Sandbox Code Playgroud)
例如,这种方法使您能够使用 Node.js 或任何其他可用的编程语言,从所选的项目管理文件(例如 )中提取版本,package.json
并自动得出正确的标签版本和名称。
Hat*_*zen 14
正如@VonC 提到的,我们必须为此创建第二个存储库。这不是禁止的,我已经在这样做了。通过 github 工作流,我自动完成了这项任务,我使用了开发/主分支,所以当我将任何东西推送到主分支时,总是会构建一个新版本并将其推送到公共“Realease”存储库。
在我的特定用例中,我正在构建一个 android apk 并通过非官方的 github api“hub”发布它。这样做的一些额外优势是您可以为外部问题和错误提供额外的问题跟踪器。
name: Master CI CD
# using checkout@v2 instead of v1 caus it needs further configuration
on:
pull_request:
types: [closed]
jobs:
UnitTest:
runs-on: ubuntu-latest
if: github.event.pull_request.merged
steps:
- uses: actions/checkout@v2
- name: make executable
run: chmod +x gradlew
- name: Unit tests
run: |
./gradlew test
IncrementVersionCode:
needs: UnitTest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: make executable
run: chmod +x gradlew
- name: increment version
run: ./gradlew incrementVersionCode
- name: Push new version to master
run: |
git config --local user.email "workflow@bot.com"
git config --local user.name "WorkflowBot"
git commit -m "Increment Build version" -a
# maybe better amend commits to avoid bot commits
BuildArtifacts:
needs: IncrementVersionCode
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: make executable
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build -x lint
- name: Rename artifacts
run: |
cp app/build/outputs/apk/release/app-release.apk MyApp.apk
- name: Upload Release
uses: actions/upload-artifact@master
with:
name: Release Apk
path: MyApp.apk
- name: Upload Debug
uses: actions/upload-artifact@master
with:
name: Debug Apk
path: app/build/outputs/apk/debug/app-debug.apk
# https://dev.to/ychescale9/running-android-emulators-on-ci-from-bitrise-io-to-github-actions-3j76
E2ETest:
needs: BuildArtifacts
runs-on: macos-latest
strategy:
matrix:
api-level: [21, 27]
arch: [x86]
steps:
- name: checkout
uses: actions/checkout@v2
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
arch: ${{ matrix.arch }}
script: ./gradlew connectedCheck
Deploy:
needs: E2ETest
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2 # Needed for gradle file to get version information
- name: Get Hub
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
cd bin
chmod +x hub
cd ..
- name: Get Apk
uses: actions/download-artifact@master
with:
name: Release Apk
- name: Publish
env:
GITHUB_TOKEN: "${{ secrets.RELEASE_REPO_SECRET }}"
run: |
APP_NAME=MyApp
VERSION_NAME=`grep -oP 'versionName "\K(.*?)(?=")' ./app/build.gradle`
VERSION_CODE=`cat version.properties | grep "VERSION_CODE" | cut -d'=' -f2`
FILENAME="${APP_NAME}-v${VERSION_NAME}-${VERSION_CODE}"
TAG="v${VERSION_NAME}-${VERSION_CODE}"
TAG="latest-master"
echo $APP_NAME
echo $VERSION_NAME
echo $VERSION_CODE
echo $FILENAME
echo $TAG
git clone https://github.com/MyUser/MyApp-Releases
cd MyApp-Releases
./../bin/hub release delete "${TAG}" || echo "Failed deleting TAG: ${TAG}" # If release got lost catch error with message
./../bin/hub release create -a "../${APP_NAME}.apk" -m "Current Master Build: ${FILENAME}" -p "${TAG}"
EvaluateCode:
needs: Deploy
runs-on: ubuntu-latest
steps:
- name: Get Hub
run: |
echo "TDOO: Run Jacoco for coverage, and other profiling tools"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7426 次 |
最近记录: |