-
Notifications
You must be signed in to change notification settings - Fork 0
145 lines (127 loc) · 4.98 KB
/
create_release.yaml
File metadata and controls
145 lines (127 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Sync LosslessCut Release
on:
workflow_dispatch: {}
schedule:
- cron: '0 0 * * Sun'
push:
branches:
- main
paths-ignore:
- 'README.md'
- '.github/workflows/create_release.yaml'
permissions:
contents: write
actions: read
jobs:
check_new_release:
runs-on: ubuntu-latest
outputs:
check_new_release_found: ${{ steps.compare.outputs.new_release }}
tag_name: ${{ steps.get_release.outputs.tag_name }}
asset_url: ${{ steps.get_release.outputs.asset_url }}
rls_body: ${{ steps.get_release.outputs.rls_body }}
steps:
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v3
- name: Get Latest Release Info
id: get_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Fetching latest release from mifi/lossless-cut..."
RELEASE_INFO=$(gh api repos/mifi/lossless-cut/releases/latest)
TAG_NAME=$(echo "$RELEASE_INFO" | jq -r .tag_name)
RLS_BODY=$(echo "$RELEASE_INFO" | jq -r .body)
ASSET_URL=$(echo "$RELEASE_INFO" | jq -r '.assets[] | select(.name | endswith("win-x64.7z")) | .browser_download_url')
if [ -z "$ASSET_URL" ]; then
echo "No .7z asset found in the latest release."
exit 1
fi
echo "Latest release tag: $TAG_NAME"
echo "Asset URL: $ASSET_URL"
echo "RLS Body: $RLS_BODY"
# Use a delimiter to preserve newlines in rls_body
echo "rls_body<<EOF" >> $GITHUB_OUTPUT
echo "$RLS_BODY" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
echo "asset_url=$ASSET_URL" >> $GITHUB_OUTPUT
- name: Compare Release Version
id: compare
env:
TAG_NAME: ${{ steps.get_release.outputs.tag_name }}
run: |
echo "Retrieving latest processed version..."
if [ -f LATEST_RELEASE ]; then
LATEST_PROCESSED_VERSION=$(cat LATEST_RELEASE)
else
LATEST_PROCESSED_VERSION=""
fi
echo "Latest processed version: $LATEST_PROCESSED_VERSION"
echo "New release version: $TAG_NAME"
if [ "$LATEST_PROCESSED_VERSION" == "$TAG_NAME" ]; then
echo "No new release found. Exiting."
echo "new_release=false" >> $GITHUB_OUTPUT
else
echo "New release found. Proceeding."
echo "new_release=true" >> $GITHUB_OUTPUT
fi
sync_release:
runs-on: ubuntu-latest
needs: [check_new_release]
if: needs.check_new_release.outputs.check_new_release_found == 'true'
steps:
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v3
# Use outputs from the check_new_release job (avoids refetching)
# Download the .7z asset
- name: Download .7z Asset
env:
ASSET_URL: ${{ needs.check_new_release.outputs.asset_url }}
run: |
echo "Downloading .7z file..."
curl -L "$ASSET_URL" --output losslesscut.7z
# Extract the .7z archive
- name: Extract 7zip Archive
run: |
sudo apt-get update && sudo apt-get install -y p7zip-full
mkdir losslesscut_extracted
7z x -olosslesscut_extracted losslesscut.7z
# Create a .zip file with the version number in the file name
- name: Create Zip Archive with Version
id: create_zip
env:
TAG_NAME: ${{ needs.check_new_release.outputs.tag_name }}
run: |
ZIP_FILENAME="losslesscut-$TAG_NAME.zip"
cd losslesscut_extracted
zip -r "../$ZIP_FILENAME" ./*
cd ..
echo "Created zip file: $ZIP_FILENAME"
echo "zip_filename=$ZIP_FILENAME" >> $GITHUB_OUTPUT
# Create a release and upload the .zip file
- name: Create Release and Upload Asset
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: "losslesscut-${{ needs.check_new_release.outputs.tag_name }}"
name: "LosslessCut ${{ needs.check_new_release.outputs.tag_name }}"
body: ${{ needs.check_new_release.outputs.rls_body }}
draft: false
prerelease: false
artifacts: ${{ steps.create_zip.outputs.zip_filename }}
# Save the processed version
- name: Save Processed Release Version
run: echo "${{ needs.check_new_release.outputs.tag_name }}" > LATEST_RELEASE
# Commit and push the updated version file
- name: Commit and Push Version File
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add LATEST_RELEASE
git commit -m "Update latest processed release to ${{ needs.check_new_release.outputs.tag_name }}"
git push