11name : Sync LosslessCut Release
22
33on :
4+ workflow_dispatch : {}
45 schedule :
56 - cron : ' 0 0 * * *'
67 push :
1011 - ' README.md'
1112 - ' .github/workflows/create_release.yaml'
1213
14+ permissions :
15+ contents : write
16+ actions : read
17+
1318jobs :
1419 check_new_release :
1520 runs-on : ubuntu-latest
1621 outputs :
17- check_new_release_found : ${{ steps.check_new_release.outputs.new_release }}
22+ check_new_release_found : ${{ steps.compare.outputs.new_release }}
23+ tag_name : ${{ steps.get_release.outputs.tag_name }}
24+ asset_url : ${{ steps.get_release.outputs.asset_url }}
25+ rls_body : ${{ steps.get_release.outputs.rls_body }}
1826 steps :
1927 # Checkout the repository
2028 - name : Checkout Repository
2331 - name : Get Latest Release Info
2432 id : get_release
2533 env :
26- GITHUB_TOKEN : ${{ secrets.MY_GITHUB_ACTION_TOKEN }}
34+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
2735 run : |
2836 echo "Fetching latest release from mifi/lossless-cut..."
2937 RELEASE_INFO=$(gh api repos/mifi/lossless-cut/releases/latest)
@@ -41,15 +49,17 @@ jobs:
4149 echo "RLS Body: $RLS_BODY"
4250
4351 # Use a delimiter to preserve newlines in rls_body
44- echo "rls_body<<EOF" >> $GITHUB_ENV
45- echo "$RLS_BODY" >> $GITHUB_ENV
46- echo "EOF" >> $GITHUB_ENV
52+ echo "rls_body<<EOF" >> $GITHUB_OUTPUT
53+ echo "$RLS_BODY" >> $GITHUB_OUTPUT
54+ echo "EOF" >> $GITHUB_OUTPUT
4755
48- echo "tag_name=$TAG_NAME" >> $GITHUB_ENV
49- echo "asset_url=$ASSET_URL" >> $GITHUB_ENV
56+ echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
57+ echo "asset_url=$ASSET_URL" >> $GITHUB_OUTPUT
5058
5159 - name : Compare Release Version
5260 id : compare
61+ env :
62+ TAG_NAME : ${{ steps.get_release.outputs.tag_name }}
5363 run : |
5464 echo "Retrieving latest processed version..."
5565 if [ -f LATEST_RELEASE ]; then
5868 LATEST_PROCESSED_VERSION=""
5969 fi
6070 echo "Latest processed version: $LATEST_PROCESSED_VERSION"
61- echo "New release version: ${{ env.tag_name }} "
71+ echo "New release version: $TAG_NAME "
6272
63- if [ "$LATEST_PROCESSED_VERSION" == "${{ env.tag_name }} " ]; then
73+ if [ "$LATEST_PROCESSED_VERSION" == "$TAG_NAME " ]; then
6474 echo "No new release found. Exiting."
6575 echo "new_release=false" >> $GITHUB_OUTPUT
6676 else
@@ -76,44 +86,15 @@ jobs:
7686 # Checkout the repository
7787 - name : Checkout Repository
7888 uses : actions/checkout@v3
79-
80- # Get the latest release info from LosslessCut
81- - name : Get Latest Release Info
82- id : get_release
83- env :
84- GITHUB_TOKEN : ${{ secrets.MY_GITHUB_ACTION_TOKEN }}
85- run : |
86- echo "Fetching latest release from mifi/lossless-cut..."
87- RELEASE_INFO=$(gh api repos/mifi/lossless-cut/releases/latest)
88- TAG_NAME=$(echo "$RELEASE_INFO" | jq -r .tag_name)
89- RLS_BODY=$(echo "$RELEASE_INFO" | jq -r .body)
90- ASSET_URL=$(echo "$RELEASE_INFO" | jq -r '.assets[] | select(.name | endswith("win-x64.7z")) | .browser_download_url')
91-
92- if [ -z "$ASSET_URL" ]; then
93- echo "No .7z asset found in the latest release."
94- exit 1
95- fi
96-
97- echo "Latest release tag: $TAG_NAME"
98- echo "Asset URL: $ASSET_URL"
99- echo "RLS Body: $RLS_BODY"
100-
101- # Use a delimiter to preserve newlines in rls_body
102- echo "rls_body<<EOF" >> $GITHUB_ENV
103- echo "$RLS_BODY" >> $GITHUB_ENV
104- echo "EOF" >> $GITHUB_ENV
105-
106- echo "tag_name=$TAG_NAME" >> $GITHUB_ENV
107- echo "asset_url=$ASSET_URL" >> $GITHUB_ENV
108-
109-
110-
89+ # Use outputs from the check_new_release job (avoids refetching)
11190
11291 # Download the .7z asset
11392 - name : Download .7z Asset
93+ env :
94+ ASSET_URL : ${{ needs.check_new_release.outputs.asset_url }}
11495 run : |
11596 echo "Downloading .7z file..."
116- curl -L "${{ env.asset_url }} " --output losslesscut.7z
97+ curl -L "$ASSET_URL " --output losslesscut.7z
11798
11899 # Extract the .7z archive
119100 - name : Extract 7zip Archive
@@ -124,38 +105,41 @@ jobs:
124105
125106 # Create a .zip file with the version number in the file name
126107 - name : Create Zip Archive with Version
108+ id : create_zip
109+ env :
110+ TAG_NAME : ${{ needs.check_new_release.outputs.tag_name }}
127111 run : |
128- ZIP_FILENAME="losslesscut-${{ env.tag_name }} .zip"
112+ ZIP_FILENAME="losslesscut-$TAG_NAME .zip"
129113 cd losslesscut_extracted
130114 zip -r "../$ZIP_FILENAME" ./*
131115 cd ..
132116 echo "Created zip file: $ZIP_FILENAME"
133- echo "zip_filename=$ZIP_FILENAME" >> $GITHUB_ENV
117+ echo "zip_filename=$ZIP_FILENAME" >> $GITHUB_OUTPUT
134118
135119 # Create a release and upload the .zip file
136120 - name : Create Release and Upload Asset
137121 uses : ncipollo/release-action@v1
138122 with :
139123 token : ${{ secrets.GITHUB_TOKEN }}
140- tag : " losslesscut-${{ env .tag_name }}"
141- name : " LosslessCut ${{ env .tag_name }}"
142- body : " ${{ env. rls_body }}"
124+ tag : " losslesscut-${{ needs.check_new_release.outputs .tag_name }}"
125+ name : " LosslessCut ${{ needs.check_new_release.outputs .tag_name }}"
126+ body : ${{ needs.check_new_release.outputs. rls_body }}
143127 draft : false
144128 prerelease : false
145- artifacts : ${{ env .zip_filename }}
129+ artifacts : ${{ steps.create_zip.outputs .zip_filename }}
146130
147131 # Save the processed version
148132 - name : Save Processed Release Version
149- run : echo "${{ env .tag_name }}" > LATEST_RELEASE
133+ run : echo "${{ needs.check_new_release.outputs .tag_name }}" > LATEST_RELEASE
150134
151135 # Commit and push the updated version file
152136 - name : Commit and Push Version File
153137
154138 env :
155- GITHUB_TOKEN : ${{ secrets.MY_GITHUB_ACTION_TOKEN }}
139+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
156140 run : |
157141 git config --global user.name "github-actions[bot]"
158142 git config --global user.email "github-actions[bot]@users.noreply.github.com"
159143 git add LATEST_RELEASE
160- git commit -m "Update latest processed release to ${{ env .tag_name }}"
144+ git commit -m "Update latest processed release to ${{ needs.check_new_release.outputs .tag_name }}"
161145 git push
0 commit comments