Skip to content

Commit

Permalink
WIP:feat: update update version file workflows. (#576)
Browse files Browse the repository at this point in the history
* update dockerfile contents.

* update field.

* feat: update update version file workflows.

* feat: add version file.

* Update version

* update log module.
  • Loading branch information
mo3et authored Sep 29, 2024
1 parent 200c392 commit 64bd8e7
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 4 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/update-version-file-on-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Update Version File on Release

on:
release:
types: [created]

jobs:
update-version:
runs-on: ubuntu-latest
env:
TAG_VERSION: ${{ github.event.release.tag_name }}
steps:
# Step 1: Checkout the original repository's code
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

# Step 2: Set up Git with official account
- name: Set up Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Step 3: Check and delete existing tag
- name: Check and delete existing tag
run: |
if git rev-parse ${{ env.TAG_VERSION }} >/dev/null 2>&1; then
git tag -d ${{ env.TAG_VERSION }}
git push --delete origin ${{ env.TAG_VERSION }}
fi
# Step 4: Update version file
- name: Update version file
run: |
echo "${{ env.TAG_VERSION }}" > version/version
# Step 5: Commit and push changes
- name: Commit and push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git add version/version
git commit -m "Update version to ${{ env.TAG_VERSION }}"
git push origin HEAD:${{ github.ref }}
# Step 6: Create and push tag
- name: Create and push tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag ${{ env.TAG_VERSION }}
git push origin ${{ env.TAG_VERSION }}
# Step 8: Find and Publish Draft Release
- name: Find and Publish Draft Release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
// Get the list of releases
const releases = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
});
// Find the draft release where the title and tag_name are the same
const draftRelease = releases.data.find(release =>
release.draft && release.name === release.tag_name
);
if (draftRelease) {
// Publish the draft release using the release_id
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: draftRelease.id, // Use release_id
draft: false
});
core.info(`Draft Release ${draftRelease.tag_name} published successfully.`);
} else {
core.info("No matching draft release found.");
}
2 changes: 2 additions & 0 deletions config/log.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ remainLogLevel: 6
isStdout: false
# Whether to log in JSON format, default is acceptable
isJson: false
# output simplify log when KeyAndValues's value len is bigger than 50 in rpc method log
isSimplify: true
8 changes: 4 additions & 4 deletions pkg/common/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"path/filepath"

"github.com/openimsdk/chat/pkg/common/config"
"github.com/openimsdk/chat/version/version"

"github.com/openimsdk/tools/errs"
"github.com/openimsdk/tools/log"
Expand Down Expand Up @@ -121,16 +122,15 @@ func (r *RootCmd) initializeLogger(cmdOpts *CmdOpts) error {
err := log.InitLoggerFromConfig(
cmdOpts.loggerPrefixName,
r.processName,
"",
"",
"", "",
r.log.RemainLogLevel,
r.log.IsStdout,
r.log.IsJson,
r.log.StorageLocation,
r.log.RemainRotationCount,
r.log.RotationTime,
config.Version,
false,
version.Version,
r.log.IsSimplify,
)
if err != nil {
return errs.Wrap(err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
_ "embed"

"github.com/openimsdk/tools/db/mongoutil"
"github.com/openimsdk/tools/db/redisutil"
)
Expand Down Expand Up @@ -165,5 +166,6 @@ type Log struct {
RemainLogLevel int `mapstructure:"remainLogLevel"`
IsStdout bool `mapstructure:"isStdout"`
IsJson bool `mapstructure:"isJson"`
IsSimplify bool `mapstructure:"isSimplify"`
WithStack bool `mapstructure:"withStack"`
}
1 change: 1 addition & 0 deletions version/version/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.8.1
6 changes: 6 additions & 0 deletions version/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package version

import _ "embed"

//go:embed version
var Version string

0 comments on commit 64bd8e7

Please sign in to comment.