Skip to content

Commit

Permalink
chore: update create-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
0x696c757a696f committed Apr 16, 2024
1 parent 251d6fa commit 556fbc6
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions .github/workflows/create-release.yml
Expand Up @@ -6,7 +6,10 @@ on:
jobs:
release:
runs-on: ubuntu-latest
permissions: write-all
permissions:
contents: write
actions: write

steps:
- name: Set up environment variables
run: |
Expand All @@ -15,17 +18,15 @@ jobs:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: 'main'

- name: Zip main branch files excluding .git and .github
run: zip -r xmjd6.zip . -x "*.git*" -x "*.github*"

- name: Zip main branch pure files
run: |
run: |
mkdir -p Rime/
rsync -avm --exclude='.git*' --exclude='*.github*' --exclude='squirrel*' --exclude='weasel*' --exclude='hamster*' --exclude='xmjd6.zip' . Rime/
ls -al Rime/
ls -al Rime/
pwd
- name: Get latest release tag
Expand All @@ -41,6 +42,30 @@ jobs:
console.log(`Latest release tag is ${tagName}`);
return tagName;
- name: Fetch tags and generate changelog from last release
id: changelog
uses: actions/github-script@v7
with:
script: |
const lastRelease = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
const compare = await github.rest.repos.compareCommits({
owner: context.repo.owner,
repo: context.repo.repo,
base: lastRelease.data.tag_name,
head: 'main'
});
let changelog = '';
compare.data.commits.forEach(commit => {
const message = commit.commit.message.split('\n').join(' ');
const commitLink = `[${commit.sha.substring(0, 7)}](https://github.com/${context.repo.owner}/${context.repo.repo}/commit/${commit.sha})`;
changelog += `- ${commitLink} ${message} \n`;
});
core.setOutput('changelog', changelog);
- name: Set the tag as environment variable
run: echo "RELEASE_TAG=${{ steps.get_tag.outputs.result }}" >> $GITHUB_ENV

Expand Down Expand Up @@ -68,6 +93,7 @@ jobs:
cp -r Rime/. Rabbit/SharedSupport
zip -r Rabbit-xmjd6.zip Rabbit/
- name: Create Release
id: create_release
uses: shogo82148/actions-create-release@v1
Expand All @@ -77,11 +103,13 @@ jobs:
tag_name: ${{ env.CURRENT_DATE }}
release_name: ${{ env.RELEASE_TITLE }}
body: |
## Changelog
${{ steps.changelog.outputs.changelog }}
## Release Notes
- [如何使用](https://github.com/hugh7007/xmjd6-rere#%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8)
draft: false
prerelease: false

- name: Upload Rabbit-xmjd6.zip to Release
uses: shogo82148/actions-upload-release-asset@v1
env:
Expand All @@ -91,7 +119,7 @@ jobs:
asset_path: ./Rabbit-xmjd6.zip
asset_name: Rabbit-xmjd6.zip
asset_content_type: application/zip

- name: Upload xmjd6.zip to Release
uses: shogo82148/actions-upload-release-asset@v1
env:
Expand Down

0 comments on commit 556fbc6

Please sign in to comment.