自迁移出 MediaWiki 以来,本页内容尚未经过审查。如果您愿意帮忙,请查看帮助指南!
This guide is intended for maintaining non-core update sites by automating builds with GitHub Actions.
- The core update sites are updated manually or automatically. Automated update is performed with GitHub Actions.
- GitHub Actions is useful because it can freely build any open source project with minimal effort.
要求
- GitHub 上托管的开源项目
- initialized upload password。
其他资源
通过 GitHub Actions 自动上传
GitHub Actions 可用于自动构建存储库以响应代码更改。为了简化 ImageJ 更新站点的维护,我们可以使用 GitHub Actions 自动上传站点的最新版本。这是通过在更新站点的 GitHub 存储库中创建一个 .github/workflows/release.yml 文件来完成的,该文件执行以下操作:
- 创建一个新的ImageJ2.app
- 构建更新站点的存储库并将所需的工件(例如
.jars)移动到 ImageJ2.app 中的预期位置 - 将本地更新站点状态上传到您的Wiki更新站点
作为起点,您可以复制以下.github/workflows/release.yml:
name: Release to Update Site
on:
push:
branches: [master] # Trigger the workflow on push to the master branch
jobs:
build_release:
runs-on: ubuntu-latest
env:
IJ_DOWNLOAD_URL: https://downloads.imagej.net/fiji/latest/fiji-linux64.zip
WIKI_USER: YOUR_USER_NAME
UPDATE_PASS: ${{ secrets.UPDATE_PASS }} # DO NOT WRITE your password here
UPDATE_SITE: YOUR_UPDATE_SITE_NAME
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build with Maven
run: mvn -B package
- name: Install ImageJ/Fiji
run: |
curl --silent -O ${IJ_DOWNLOAD_URL}
unzip fiji-linux64.zip
./Fiji.app/ImageJ-linux64 --headless --update edit-update-site ${UPDATE_SITE} https://sites.imagej.net/${UPDATE_SITE}/ "webdav:${WIKI_USER}:${UPDATE_PASS}" .
- name: Install in ImageJ/Fiji (with Maven)
run: mvn -B install -Dscijava.app.directory=./Fiji.app -Ddelete.other.versions=true -Dscijava.ignoreDependencies=true
- name: Release to ImageJ update site
run: |
./Fiji.app/ImageJ-linux64 --headless --update upload-complete-site --force ${UPDATE_SITE}
不要忘记用您的信息替换 WIKI_USER 和 UPDATE_SITE 变量。
加密你的密码
要上传到您的 wiki 更新站点,您需要向 GitHub Actions 提供 UPDATE_PASS 环境变量,该变量应评估为执行上传的 Wiki 帐户的upload password。为了安全地执行此操作,请遵循creating encrypted secrets for a repository中的说明。
非 Maven 化文件
GitHub Actions 还能够构建除 Java 之外的多种语言。如果您无法将 Maven 与 scijava.app.directory 一起使用,那么您需要替换 .github/workflows/release.yml 的以下行:
mvn -B install -Dscijava.app.directory=./Fiji.app -Ddelete.other.versions=true -Dscijava.ignoreDependencies=true
使用一系列命令将您的构建工件移动到适合您的更新站点的 ./Fiji.app/jars 或 ./Fiji.app/plugins 目录。
如果您有自定义脚本、宏等,情况也是如此……如果这些文件没有出现在本地 ImageJ2.app 的正确位置,它们将看起来已被删除。
注意事项
USE CAUTION HERE
- You are configuring GitHub Actions to upload the state of an ImageJ installation to your update site. The ImageJ2.app that will be uploaded is located at
./Fiji.appwith respect to the current working directory of the virtual machine GitHub Actions is running on. If your build artifacts are not located in the./Fiji.app/jarsor./Fiji.app/pluginsdirectory, or you don’t manually copy scripts to the correct location, ImageJ will see these items as having been deleted—effectively removing all content from your update site. You can mitigate this danger by customizing yourrelease.ymlto download your own update site into the base ImageJ2.app; only changes to the update site state will be uploaded. - By default—building the master branch of your repository—your update site will be updated with every change to the source code. Although we encourage the master branch to be “release ready”, a safer practice would be to configure GitHub Actions to only build specific events—and set it to build release versions only—e.g. with a release version integration branch.
- Using the Maven-based
release.ymlas suggested implies that you are conforming to the managed dependencies of the parent pom.xml. If you are not staying up-to-date with the ImageJ and Fiji update sites (by using the latest ImageJ or Fiji bill of materials) then this automation may break your own update site.