Skip to content

Commit 5edb792

Browse files
authored
Use environment variables in GitHub workflows (#8500)
1 parent dcdea1d commit 5edb792

5 files changed

Lines changed: 78 additions & 48 deletions

File tree

.github/workflows/autoMerge.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ jobs:
1515
shell: bash
1616
env:
1717
GH_TOKEN: ${{ secrets.PUSH_TOKEN }}
18-
run: gh pr merge https://github.com/FreeTubeApp/FreeTube/pull/${{ github.event.pull_request.number }} --auto --squash
18+
PR_NUMBER: ${{ github.event.pull_request.number }}
19+
run: gh pr merge "https://github.com/FreeTubeApp/FreeTube/pull/${PR_NUMBER}" --auto --squash

.github/workflows/build.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,19 @@ jobs:
8181
id: versionNumber
8282
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0
8383
env:
84-
IS_DEV: ${{ contains(github.ref, 'development') }}
85-
IS_RC: ${{ contains(github.ref, 'RC') }}
8684
VERSION_NUMBER_NIGHTLY: ${{ steps.getPackageInfo.outputs.version }}-nightly-${{ github.run_number }}
8785
VERSION_NUMBER_RC: ${{ steps.getPackageInfo.outputs.version }}-RC-${{ github.run_number }}
8886
VERSION_NUMBER: ${{ steps.getPackageInfo.outputs.version }}
8987
with:
9088
result-encoding: string
9189
script: |
92-
if (${{ env.IS_DEV }}) {
93-
return "${{ env.VERSION_NUMBER_NIGHTLY }}"
94-
} else if (${{ env.IS_RC }}) {
95-
return "${{ env.VERSION_NUMBER_RC }}"
90+
if (context.ref.toLowerCase().includes('development')) {
91+
return `${process.env.VERSION_NUMBER_NIGHTLY}`
92+
} else if (context.ref.toUpperCase().includes('RC')) {
93+
return `${process.env.VERSION_NUMBER_RC}`
9694
} else {
97-
return "${{env.VERSION_NUMBER }}"
95+
return `${process.env.VERSION_NUMBER}`
9896
}
99-
# script: if ${{ env.IS_DEV }} then echo "::set-output name=VERSION_NUMBER::${{ env.VERSION_NUMBER_NIGHTLY }}" else echo "::set-output name=VERSION_NUMBER::${{ env.VERSION_NUMBER }}" fi
10097
10198
- name: Update package.json version
10299
uses: jaywcjlove/github-action-package@ee84f0c52bd8de8d25601af0402a9059320cb87a
@@ -128,10 +125,12 @@ jobs:
128125
- name: Convert X64 AppImage to static runtime
129126
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.runtime, 'linux-x64')
130127
shell: bash
128+
env:
129+
VERSION: ${{ steps.versionNumber.outputs.result }}
131130
run: |
132131
sudo apt install desktop-file-utils
133132
cd build
134-
appimage="FreeTube-${{ steps.versionNumber.outputs.result }}.AppImage"
133+
appimage="FreeTube-${VERSION}.AppImage"
135134
wget "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" -O ./appimagetool.AppImage
136135
chmod +x ./"$appimage" ./appimagetool.AppImage
137136
./"$appimage" --appimage-extract && rm -f ./"$appimage"

.github/workflows/flatpak.yml

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ jobs:
5151
v: ''
5252
- name: Create Release Branch
5353
shell: bash
54+
env:
55+
VERSION: ${{ steps.sub.outputs.result }}
5456
run: |
55-
git checkout -b release-v${{ steps.sub.outputs.result }}
56-
git push --set-upstream origin release-v${{ steps.sub.outputs.result }}
57+
git checkout -b "release-v${VERSION}"
58+
git push --set-upstream origin "release-v${VERSION}"
5759
- name: Download x64 Release
5860
uses: fabriciobastian/download-release-asset-action@35e62aa5a2fe4a6ec79004f6052918349013ae4f #v1.0.6
5961
with:
@@ -67,54 +69,72 @@ jobs:
6769
repository: FreeTubeApp/FreeTube
6870
file: freetube-${{ steps.sub.outputs.result }}-beta-linux-arm64-portable.zip
6971
- name: Set x64 Hash Variable
70-
id: hash-x64
72+
id: hash_x64
7173
shell: bash
74+
env:
75+
VERSION: ${{ steps.sub.outputs.result }}
7276
run: |
73-
echo 'HASH_X64<<EOF' >> $GITHUB_ENV
74-
sha256sum freetube-${{ steps.sub.outputs.result }}-beta-linux-x64-portable.zip | awk '{print $1}' >> $GITHUB_ENV
75-
echo 'EOF' >> $GITHUB_ENV
77+
echo 'HASH_X64<<EOF' >> "$GITHUB_OUTPUT"
78+
sha256sum "freetube-${VERSION}-beta-linux-x64-portable.zip" | awk '{print $1}' >> "$GITHUB_OUTPUT"
79+
echo 'EOF' >> "$GITHUB_OUTPUT"
7680
- name: Set ARM Hash Variable
77-
id: hash-arm64
81+
id: hash_arm64
7882
shell: bash
83+
env:
84+
VERSION: ${{ steps.sub.outputs.result }}
7985
run: |
80-
echo 'HASH_ARM64<<EOF' >> $GITHUB_ENV
81-
sha256sum freetube-${{ steps.sub.outputs.result }}-beta-linux-arm64-portable.zip | awk '{print $1}' >> $GITHUB_ENV
82-
echo 'EOF' >> $GITHUB_ENV
86+
echo 'HASH_ARM64<<EOF' >> "$GITHUB_OUTPUT"
87+
sha256sum "freetube-${VERSION}-beta-linux-arm64-portable.zip" | awk '{print $1}' >> "$GITHUB_OUTPUT"
88+
echo 'EOF' >> "$GITHUB_OUTPUT"
89+
8390
- name: Set Date Variable
84-
id: current-date
91+
id: current_date
8592
shell: bash
8693
run: |
87-
echo 'CURRENT_DATE<<EOF' >> $GITHUB_ENV
88-
date +"%Y-%m-%d" >> $GITHUB_ENV
89-
echo 'EOF' >> $GITHUB_ENV
94+
echo 'CURRENT_DATE<<EOF' >> "$GITHUB_OUTPUT"
95+
date +"%Y-%m-%d" >> "$GITHUB_OUTPUT"
96+
echo 'EOF' >> "$GITHUB_OUTPUT"
9097
- name: Update x64 File Location in yml File
91-
uses: mikefarah/yq@065b200af9851db0d5132f50bc10b1406ea5c0a8 #v4.50.1
92-
with:
93-
# The Command which should be run
94-
cmd: yq -i '.modules[0].sources[0].url = "https://github.com/FreeTubeApp/FreeTube/releases/download/v${{ steps.sub.outputs.result }}-beta/freetube-${{ steps.sub.outputs.result }}-beta-linux-x64-portable.zip"' io.freetubeapp.FreeTube.yml
98+
shell: bash
99+
env:
100+
VERSION: steps.sub.outputs.result
101+
run: |
102+
yq -i '.modules[0].sources[0].url = "https://github.com/FreeTubeApp/FreeTube/releases/download/v" + strenv(VERSION) + "-beta/freetube-" + strenv(VERSION) + "-beta-linux-x64-portable.zip"' io.freetubeapp.FreeTube.yml
103+
95104
- name: Update x64 Hash in yml File
96-
uses: mikefarah/yq@065b200af9851db0d5132f50bc10b1406ea5c0a8 #v4.50.1
97-
with:
98-
# The Command which should be run
99-
cmd: yq -i '.modules[0].sources[0].sha256 = "${{ env.HASH_X64 }}"' io.freetubeapp.FreeTube.yml
105+
shell: bash
106+
env:
107+
HASH_X64: ${{ steps.hash_x64.outputs.HASH_X64 }}
108+
run: |
109+
yq -i '.modules[0].sources[0].sha256 = strenv(HASH_X64)' io.freetubeapp.FreeTube.yml
110+
100111
- name: Update ARM File Location in yml File
101-
uses: mikefarah/yq@065b200af9851db0d5132f50bc10b1406ea5c0a8 #v4.50.1
102-
with:
103-
# The Command which should be run
104-
cmd: yq -i '.modules[0].sources[1].url = "https://github.com/FreeTubeApp/FreeTube/releases/download/v${{ steps.sub.outputs.result }}-beta/freetube-${{ steps.sub.outputs.result }}-beta-linux-arm64-portable.zip"' io.freetubeapp.FreeTube.yml
112+
shell: bash
113+
env:
114+
VERSION: steps.sub.outputs.result
115+
run: |
116+
yq -i '.modules[0].sources[1].url = "https://github.com/FreeTubeApp/FreeTube/releases/download/v" + strenv(VERSION) + "-beta/freetube-" + strenv(VERSION) + "-beta-linux-arm64-portable.zip"' io.freetubeapp.FreeTube.yml
117+
105118
- name: Update ARM Hash in yml File
106-
uses: mikefarah/yq@065b200af9851db0d5132f50bc10b1406ea5c0a8 #v4.50.1
107-
with:
108-
# The Command which should be run
109-
cmd: yq -i '.modules[0].sources[1].sha256 = "${{ env.HASH_ARM64 }}"' io.freetubeapp.FreeTube.yml
119+
shell: bash
120+
env:
121+
HASH_ARM64: ${{ steps.hash_arm64.outputs.HASH_ARM64 }}
122+
run: |
123+
yq -i '.modules[0].sources[1].sha256 = strenv(HASH_ARM64)' io.freetubeapp.FreeTube.yml
124+
110125
- name: Add Patch Notes to XML File
111126
shell: bash
112-
run: xmlstarlet ed -L -i /component/releases/release[1] -t elem -n releaseTMP -v "" -i //releaseTMP -t attr -n version -v "${{ steps.sub.outputs.result }} Beta" -i //releaseTMP -t attr -n date -v "${{ env.CURRENT_DATE }}" -s //releaseTMP -t elem -n url -v "" -s //releaseTMP/url -t text -n "" -v "https://github.com/FreeTubeApp/FreeTube/releases/tag/v${{ steps.sub.outputs.result }}-beta" -r //releaseTMP -v "release" io.freetubeapp.FreeTube.metainfo.xml
127+
env:
128+
CURRENT_DATE: ${{ steps.current_date.outputs.current_date }}
129+
VERSION: ${{ steps.sub.outputs.result }}
130+
run: xmlstarlet ed -L -i /component/releases/release[1] -t elem -n releaseTMP -v "" -i //releaseTMP -t attr -n version -v "${VERSION} Beta" -i //releaseTMP -t attr -n date -v "${CURRENT_DATE}" -s //releaseTMP -t elem -n url -v "" -s //releaseTMP/url -t text -n "" -v "https://github.com/FreeTubeApp/FreeTube/releases/tag/v${VERSION}-beta" -r //releaseTMP -v "release" io.freetubeapp.FreeTube.metainfo.xml
113131
- name: Remove Release Files
114132
shell: bash
133+
env:
134+
VERSION: ${{ steps.sub.outputs.result }}
115135
run: |
116-
rm freetube-${{ steps.sub.outputs.result }}-beta-linux-x64-portable.zip
117-
rm freetube-${{ steps.sub.outputs.result }}-beta-linux-arm64-portable.zip
136+
rm "freetube-${VERSION}-beta-linux-x64-portable.zip"
137+
rm "freetube-${VERSION}-beta-linux-arm64-portable.zip"
118138
- name: Commit Files
119139
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 #v7.1.0
120140
with:
@@ -132,4 +152,5 @@ jobs:
132152
shell: bash
133153
env:
134154
GH_TOKEN: ${{ secrets.FLATHUB_TOKEN }}
135-
run: gh pr create --title "Release v${{ steps.sub.outputs.result }}" --body "This is an automated PR for the v${{ steps.sub.outputs.result }} release. This PR will be updated and merged once testing is complete."
155+
VERSION: ${{ steps.sub.outputs.result }}
156+
run: gh pr create --title "Release v${VERSION}" --body "This is an automated PR for the v${VERSION} release. This PR will be updated and merged once testing is complete."

.github/workflows/release.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ jobs:
108108
- name: Convert X64 AppImage to static runtime and add update information
109109
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.runtime, 'linux-x64')
110110
shell: bash
111+
env:
112+
VERSION: ${{ steps.getPackageInfo.outputs.version }}
111113
run: |
112114
sudo apt install desktop-file-utils
113115
cd build
114-
appimage="FreeTube-${{ steps.getPackageInfo.outputs.version }}.AppImage"
116+
appimage="FreeTube-${VERSION}.AppImage"
115117
wget "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" -O ./appimagetool.AppImage
116118
chmod +x ./"$appimage" ./appimagetool.AppImage
117119
update_information="gh-releases-zsync|FreeTubeApp|FreeTube|latest-all|freetube-*-amd64.AppImage.zsync"
@@ -123,10 +125,12 @@ jobs:
123125
- name: Convert ARMv7l AppImage to static runtime and add update information
124126
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.runtime, 'linux-armv7l')
125127
shell: bash
128+
env:
129+
VERSION: ${{ steps.getPackageInfo.outputs.version }}
126130
run: |
127131
sudo apt install desktop-file-utils
128132
cd build
129-
appimage="FreeTube-${{ steps.getPackageInfo.outputs.version }}.AppImage"
133+
appimage="FreeTube-${VERSION}.AppImage"
130134
wget "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" -O ./appimagetool.AppImage
131135
wget "https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-x86_64" -O runtime
132136
chmod +x ./"$appimage" ./appimagetool.AppImage ./runtime
@@ -139,10 +143,12 @@ jobs:
139143
- name: Convert ARM64 AppImage to static runtime and add update information
140144
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.runtime, 'linux-arm64')
141145
shell: bash
146+
env:
147+
VERSION: ${{ steps.getPackageInfo.outputs.version }}
142148
run: |
143149
sudo apt install desktop-file-utils
144150
cd build
145-
appimage="FreeTube-${{ steps.getPackageInfo.outputs.version }}.AppImage"
151+
appimage="FreeTube-${VERSION}.AppImage"
146152
wget "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage" -O ./appimagetool.AppImage
147153
wget "https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-x86_64" -O runtime
148154
chmod +x ./"$appimage" ./appimagetool.AppImage ./runtime

.github/workflows/updateSite.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ jobs:
6060
git checkout master
6161
- name: Update index.php
6262
shell: bash
63+
env:
64+
CURRENT: ${{ steps.current.outputs.result }}
65+
PREVIOUS: ${{ steps.previous.outputs.result }}
6366
run: |
64-
sed -i 's/${{ steps.previous.outputs.result }}/${{ steps.current.outputs.result }}/g' src/index.php
67+
sed -i "s/${PREVIOUS}/${CURRENT}/g" src/index.php
6568
- name: Commit Files
6669
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 #v7.1.0
6770
with:

0 commit comments

Comments
 (0)