Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
almighty.yantao committed Jul 19, 2024
1 parent e05d9d7 commit cca3daf
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions .github/workflows/compress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,42 @@ jobs:
run: echo "::set-output name=sha256::$(sha256sum src.zip | awk '{print $1}')"
working-directory: ${{ github.workspace }}

- name: Read appcast.json
id: read_appcast
run: |
echo ::set-output name=appcast::$(cat src/appcast.json)
working-directory: ${{ github.workspace }}

- name: Determine next version
id: next_version
run: |
versions=$(jq '.versions[].version' src/appcast.json)
max_version=$(echo "$versions" | sort -rV | head -n1)
next_version=$(echo "$max_version + 0.0.1" | bc)
echo "::set-output name=next_version::$next_version"
shell: bash
working-directory: ${{ github.workspace }}

- name: Modify appcast.json
run: |
# Generate the new version object to add
new_version='{
"version": "0.1.2",
"version": "${{ steps.next_version.outputs.next_version }}",
"desc": "${{ steps.commit_message.outputs.message }}",
"sha256": "${{ steps.sha256.outputs.sha256 }}",
"url": "https://github.com/almightyYantao/bob-plugin-deeplx-translator/releases/download/0.1.2/${{ steps.build.outputs.build }}.bobplugin",
"url": "https://github.com/almightyYantao/bob-plugin-deeplx-translator/releases/download/${{ steps.next_version.outputs.next_version }}/${{ steps.build.outputs.build }}.bobplugin",
"minBobVersion": "0.5.0",
"timestamp": '"$(date +%s)"'
}'
# Read the current appcast.json
appcast_file="src/appcast.json"
current_versions=$(jq '.versions' $appcast_file)
current_appcast=$(cat src/appcast.json)
# Append the new version to the existing versions array
new_versions=$(jq --argjson new_version "$new_version" '.versions += [$new_version]' <<< "$current_versions")
# Append the new version object to the versions array
new_appcast=$(jq --argjson new_version "$new_version" '.versions += [$new_version]' <<< "$current_appcast")
# Update appcast.json with the new versions array
echo $new_versions > $appcast_file
# Commit and push the updated appcast.json back to the repository
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add $appcast_file
git commit -m "Update appcast.json with new version"
git push origin main
echo "$new_appcast" > src/appcast.json
working-directory: ${{ github.workspace }}

- name: Rename zip file
Expand Down

0 comments on commit cca3daf

Please sign in to comment.