fix: remove update version file workflows have new line in 3.8.3-patch branch. (#3452)

pull/3469/head
Monet Lee 2 months ago committed by GitHub
parent 1b6d70e4a7
commit 54e189d80f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -15,12 +15,13 @@ jobs:
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
submodules: "recursive"
# Step 2: Set up Git with official account # Step 2: Set up Git with official account
- name: Set up Git - name: Set up Git
run: | run: |
git config user.name "github-actions[bot]" git config --global user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com" git config --global user.email "github-actions[bot]@users.noreply.github.com"
# Step 3: Check and delete existing tag # Step 3: Check and delete existing tag
- name: Check and delete existing tag - name: Check and delete existing tag
@ -33,7 +34,8 @@ jobs:
# Step 4: Update version file # Step 4: Update version file
- name: Update version file - name: Update version file
run: | run: |
echo "${{ env.TAG_VERSION }}" > version/version mkdir -p version
echo -n "${{ env.TAG_VERSION }}" > version/version
# Step 5: Commit and push changes # Step 5: Commit and push changes
- name: Commit and push changes - name: Commit and push changes
@ -42,43 +44,56 @@ jobs:
run: | run: |
git add version/version git add version/version
git commit -m "Update version to ${{ env.TAG_VERSION }}" git commit -m "Update version to ${{ env.TAG_VERSION }}"
git push origin HEAD:${{ github.ref }}
# Step 6: Create and push tag # Step 6: Update tag
- name: Create and push tag - name: Update tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
git tag ${{ env.TAG_VERSION }} git tag -fa ${{ env.TAG_VERSION }} -m "Update version to ${{ env.TAG_VERSION }}"
git push origin ${{ env.TAG_VERSION }} git push origin ${{ env.TAG_VERSION }} --force
# Step 7: Find and Publish Draft Release # Step 7: Find and Publish Draft Release
- name: Find and Publish Draft Release - name: Find and Publish Draft Release
uses: actions/github-script@v6 uses: actions/github-script@v7
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}
script: | script: |
// Get the list of releases const { owner, repo } = context.repo;
const tagName = process.env.TAG_VERSION;
try {
let release;
try {
const response = await github.rest.repos.getReleaseByTag({
owner,
repo,
tag: tagName
});
release = response.data;
} catch (tagError) {
core.info(`Release not found by tag, searching all releases...`);
const releases = await github.rest.repos.listReleases({ const releases = await github.rest.repos.listReleases({
owner: context.repo.owner, owner,
repo: context.repo.repo repo,
per_page: 100
}); });
// Find the draft release where the title and tag_name are the same release = releases.data.find(r => r.draft && r.tag_name === tagName);
const draftRelease = releases.data.find(release => if (!release) {
release.draft && release.name === release.tag_name throw new Error(`No release found with tag ${tagName}`);
); }
}
if (draftRelease) {
// Publish the draft release using the release_id
await github.rest.repos.updateRelease({ await github.rest.repos.updateRelease({
owner: context.repo.owner, owner,
repo: context.repo.repo, repo,
release_id: draftRelease.id, // Use release_id release_id: release.id,
draft: false draft: false,
prerelease: release.prerelease
}); });
core.info(`Draft Release ${draftRelease.tag_name} published successfully.`); const status = release.draft ? "was draft" : "was already published";
} else { core.info(`Release ${tagName} ensured to be published (${status}).`);
core.info("No matching draft release found.");
} catch (error) {
core.warning(`Could not find or update release for tag ${tagName}: ${error.message}`);
} }

@ -1,6 +1,14 @@
package version package version
import _ "embed" import (
_ "embed"
"strings"
)
//go:embed version //go:embed version
var Version string var Version string
func init() {
Version = strings.Trim(Version, "\n")
Version = strings.TrimSpace(Version)
}

Loading…
Cancel
Save