-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: schedule with cron to auto release.
Signed-off-by: Hanchin Hsieh <[email protected]>
- Loading branch information
Showing
2 changed files
with
86 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const semver = require('semver') | ||
|
||
const getLatestTag = async (github, owner, repo, tag_format) => { | ||
const { status, data } = await github.rest.git.listMatchingRefs({ | ||
owner, | ||
repo, | ||
ref: `tags/${tag_format}`, | ||
}) | ||
if (status != 200) { | ||
throw new Error(`Failed to fetch tags for ${owner}/${repo}`) | ||
} | ||
const tags = data.map((ref) => { | ||
const version = ref.ref.replace(`refs/tags/${tag_format}`, '') | ||
return version | ||
}) | ||
if (tags.length === 0) { | ||
return '0.0.0' | ||
} | ||
max_version = tags.reduce((a, b) => semver.gt(a, b) ? a : b) ?? '0.0.0' | ||
return max_version | ||
} | ||
|
||
|
||
module.exports = async ({ github }) => { | ||
const bindingTag = await getLatestTag(github, 'apache', 'opendal', 'bindings/go/v') | ||
const serviceTag = await getLatestTag(github, 'apache', 'opendal-go-services', 'v') | ||
|
||
const opendalGoVersion = semver.gt(bindingTag, serviceTag) ? `v${bindingTag}` : '' | ||
const opendalCoreVersion = `v${await getLatestTag(github, "apache", "opendal", "v")}` | ||
|
||
console.log(`opendal_core_version=${opendalCoreVersion}`) | ||
console.log(`opendal_go_version=${opendalGoVersion}`) | ||
|
||
const fs = require('fs') | ||
const output = process.env.GITHUB_OUTPUT | ||
|
||
fs.appendFileSync(output, `opendal_core_version=${opendalCoreVersion}\n`) | ||
fs.appendFileSync(output, `opendal_go_version=${opendalGoVersion}\n`) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,34 @@ | ||
name: build_artifacts | ||
on: | ||
repository_dispatch: | ||
types: [ build ] | ||
workflow_dispatch: | ||
inputs: | ||
opendal_core_version: | ||
description: "Version of Apache OpenDAL Core" | ||
required: true | ||
type: string | ||
opendal_go_version: | ||
description: "Version of Apache OpenDAL Go Binding" | ||
required: false | ||
type: string | ||
schedule: | ||
- cron: '*/5 * * * *' | ||
|
||
jobs: | ||
version_check: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
opendal_core_version: ${{ steps.set-version.outputs.opendal_core_version }} | ||
opendal_go_version: ${{ steps.set-version.outputs.opendal_go_version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
- name: Install Dependencies | ||
run: npm install semver | ||
- uses: actions/github-script@v7 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
script: | | ||
const script = require('.github/scripts/setup_version.js') | ||
await script({github}) | ||
matrix: | ||
needs: [ version_check ] | ||
runs-on: ubuntu-latest | ||
if: ${{ needs.version_check.outputs.opendal_go_version != '' }} | ||
outputs: | ||
matrix: ${{ steps.set-matrix.outputs.matrix }} | ||
steps: | ||
|
@@ -27,7 +41,7 @@ jobs: | |
echo "$MATRIX" | jq . | ||
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT | ||
build: | ||
needs: [ matrix ] | ||
needs: [ version_check, matrix ] | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
|
@@ -36,7 +50,7 @@ jobs: | |
- uses: actions/checkout@v4 | ||
with: | ||
repository: "apache/opendal" | ||
ref: ${{ inputs.opendal_core_version || github.event.client_payload.opendal_core_version }} | ||
ref: ${{ needs.version_check.outputs.opendal_core_version }} | ||
- uses: actions/checkout@v4 | ||
with: | ||
path: "tools" | ||
|
@@ -78,12 +92,12 @@ jobs: | |
zstd -22 ./target/$TARGET/release/libopendal_c.so -o ./libopendal_c.$TARGET.so.zst | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: "libopendal_c_${{ inputs.opendal_core_version || github.event.client_payload.opendal_core_version }}_${{ matrix.service }}_${{ matrix.build.target }}" | ||
name: "libopendal_c_${{ needs.version_check.outputs.opendal_core_version }}_${{ matrix.service }}_${{ matrix.build.target }}" | ||
if-no-files-found: "error" | ||
path: "bindings/c/libopendal_c.${{ matrix.build.target }}.so.zst" | ||
overwrite: "true" | ||
generate: | ||
needs: [ matrix, build ] | ||
needs: [ version_check, matrix, build ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -92,34 +106,45 @@ jobs: | |
- name: Generate Template | ||
env: | ||
MATRIX: ${{ needs.matrix.outputs.matrix }} | ||
VERSION: ${{ inputs.opendal_core_version || github.event.client_payload.opendal_core_version }} | ||
VERSION: ${{ needs.version_check.outputs.opendal_core_version }} | ||
working-directory: internal/generate | ||
run: | | ||
go run generate.go | ||
- name: Auto Commit | ||
env: | ||
VERSION: ${{ inputs.opendal_core_version || github.event.client_payload.opendal_core_version }} | ||
VERSION: ${{ needs.version_check.outputs.opendal_core_version }} | ||
TAG: ${{ needs.version_check.outputs.opendal_go_version }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config --global user.name "Github Actions" | ||
git config --global user.email "[email protected]" | ||
git add -A | ||
git commit --allow-empty -m "Auto commit by GitHub Actions $VERSION" | ||
git push -f --set-upstream origin main | ||
- name: Auto Tag | ||
if: ${{ needs.version_check.outputs.opendal_go_version != '' }} | ||
env: | ||
TAG: ${{ needs.version_check.outputs.opendal_go_version }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# The tag is used for version_check only. | ||
git tag $TAG | ||
git push -f origin $TAG | ||
tag: | ||
needs: [ matrix, build, generate ] | ||
needs: [ version_check, matrix, build, generate ] | ||
runs-on: ubuntu-latest | ||
if: ${{ needs.version_check.outputs.opendal_go_version != '' }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
service: ${{ fromJson(needs.matrix.outputs.matrix).service }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Auto Tag | ||
if: ${{ inputs.opendal_go_version != '' || github.event.client_payload.opendal_go_version != '' }} | ||
- name: Auto Service Tag | ||
env: | ||
SERVICE: ${{ matrix.service }} | ||
VERSION: ${{ inputs.opendal_go_version || github.event.client_payload.opendal_go_version }} | ||
VERSION: ${{ needs.version_check.outputs.opendal_go_version }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
SERVICE=$(echo $SERVICE | tr '-' '_') | ||
TAG="$SERVICE/$VERSION" | ||
|