This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal-go-services.git
The following commit(s) were added to refs/heads/main by this push:
new f2e8851 ci: schedule with cron to auto release. (#9)
f2e8851 is described below
commit f2e8851055abbd2b7c45d0f496152cb56dc6f4ae
Author: Hanchin Hsieh <[email protected]>
AuthorDate: Fri Aug 2 16:48:42 2024 +0800
ci: schedule with cron to auto release. (#9)
Signed-off-by: Hanchin Hsieh <[email protected]>
---
.github/scripts/setup_version.js | 40 ++++++++++++++++++++
.github/workflows/build_artifacts.yaml | 68 +++++++++++++++++++++++-----------
2 files changed, 87 insertions(+), 21 deletions(-)
diff --git a/.github/scripts/setup_version.js b/.github/scripts/setup_version.js
new file mode 100644
index 0000000..81cf448
--- /dev/null
+++ b/.github/scripts/setup_version.js
@@ -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`)
+}
+
diff --git a/.github/workflows/build_artifacts.yaml
b/.github/workflows/build_artifacts.yaml
index 82ee2a3..1b0d358 100644
--- a/.github/workflows/build_artifacts.yaml
+++ b/.github/workflows/build_artifacts.yaml
@@ -1,20 +1,35 @@
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@v4
+ with:
+ node-version: '20.x'
+ - name: Install Dependencies
+ run: npm install semver
+ - uses: actions/github-script@v7
+ id: set-version
+ 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 +42,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 +51,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 +93,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,13 +107,14 @@ 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"
@@ -106,20 +122,30 @@ jobs:
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"