2020-12-13 20:40:54 +00:00
# This is a basic workflow that is manually triggered
name : Create Flatpak PR
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on :
2020-12-18 16:27:04 +00:00
workflow_dispatch :
2020-12-13 20:40:54 +00:00
release :
types : [ published]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs :
build :
runs-on : ubuntu-latest
steps :
2022-10-01 16:26:05 +00:00
- uses : actions/checkout@v3
2020-12-13 20:40:54 +00:00
with :
repository : flathub/io.freetubeapp.FreeTube
2022-10-10 14:28:19 +00:00
token : ${{ secrets.FLATHUB_TOKEN }}
2020-12-13 20:40:54 +00:00
- name : GitHub API exec action
uses : moustacheful/github-api-exec-action@v0
id : api_results
with :
# Command to execute, (e.g: `pulls.create`), see https://octokit.github.io/rest.js/ for available commands
command : repos.getRelease
payload : >
{
2021-01-15 20:07:40 +00:00
"owner": "FreeTubeApp" ,
2020-12-13 20:40:54 +00:00
"repo": "FreeTube" ,
"release_id": ${{ secrets.UPLOAD_ID }}
}
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
- name : Install xmlstarlet
run : sudo apt -y install xmlstarlet
- name : Create Version Variable
2022-10-04 19:19:33 +00:00
uses : bluwy/substitute-string-action@v2
2020-12-13 20:40:54 +00:00
id : sub
with :
_input-text : ${{ fromJson(steps.api_results.outputs.result).tag_name }}
-beta : ''
v : ''
- name : Create Release Branch
run : |
git checkout -b release-v${{ steps.sub.outputs.result }}
git push --set-upstream origin release-v${{ steps.sub.outputs.result }}
- name : Download x64 Release
uses : fabriciobastian/download-release-asset-action@v1.0.6
with :
version : v${{ steps.sub.outputs.result }}-beta
repository : FreeTubeApp/FreeTube
file : freetube-${{ steps.sub.outputs.result }}-linux-portable-x64.zip
- name : Download ARM Release
uses : fabriciobastian/download-release-asset-action@v1.0.6
with :
version : v${{ steps.sub.outputs.result }}-beta
repository : FreeTubeApp/FreeTube
file : freetube-${{ steps.sub.outputs.result }}-linux-portable-arm64.zip
- name : Set x64 Hash Variable
id : hash-x64
run : |
echo 'HASH_X64<<EOF' >> $GITHUB_ENV
sha256sum freetube-${{ steps.sub.outputs.result }}-linux-portable-x64.zip | awk '{print $1}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name : Set ARM Hash Variable
id : hash-arm64
run : |
echo 'HASH_ARM64<<EOF' >> $GITHUB_ENV
sha256sum freetube-${{ steps.sub.outputs.result }}-linux-portable-arm64.zip | awk '{print $1}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name : Set Date Variable
id : current-date
run : |
echo 'CURRENT_DATE<<EOF' >> $GITHUB_ENV
date +"%Y-%m-%d" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name : Update x64 File Location in yml File
2022-10-05 01:11:34 +00:00
uses : mikefarah/yq@v4.27.5
2020-12-13 20:40:54 +00:00
with :
# The Command which should be run
cmd : yq w -i io.freetubeapp.FreeTube.yml modules[0].sources[0].url 'https://github.com/FreeTubeApp/FreeTube/releases/download/v${{ steps.sub.outputs.result }}-beta/freetube-${{ steps.sub.outputs.result }}-linux-portable-x64.zip'
- name : Update x64 Hash in yml File
2022-10-05 01:11:34 +00:00
uses : mikefarah/yq@v4.27.5
2020-12-13 20:40:54 +00:00
with :
# The Command which should be run
cmd : yq w -i io.freetubeapp.FreeTube.yml modules[0].sources[0].sha256 ${{ env.HASH_X64 }}
- name : Update ARM File Location in yml File
2022-10-05 01:11:34 +00:00
uses : mikefarah/yq@v4.27.5
2020-12-13 20:40:54 +00:00
with :
# The Command which should be run
cmd : yq w -i io.freetubeapp.FreeTube.yml modules[0].sources[1].url 'https://github.com/FreeTubeApp/FreeTube/releases/download/v${{ steps.sub.outputs.result }}-beta/freetube-${{ steps.sub.outputs.result }}-linux-portable-arm64.zip'
- name : Update ARM Hash in yml File
2022-10-05 01:11:34 +00:00
uses : mikefarah/yq@v4.27.5
2020-12-13 20:40:54 +00:00
with :
# The Command which should be run
cmd : yq w -i io.freetubeapp.FreeTube.yml modules[0].sources[1].sha256 ${{ env.HASH_ARM64 }}
- name : Add Patch Notes to XML File
run : xmlstarlet ed -L -i /application/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
- name : Remove Release Files
run : |
rm freetube-${{ steps.sub.outputs.result }}-linux-portable-x64.zip
rm freetube-${{ steps.sub.outputs.result }}-linux-portable-arm64.zip
- name : Commit Files
uses : stefanzweifel/git-auto-commit-action@v4
with :
# Optional but recommended
# Defaults to "Apply automatic changes"
commit_message : Update files for v${{ steps.sub.outputs.result }}
2022-10-10 14:28:19 +00:00
token : ${{ secrets.FLATHUB_TOKEN }}
2020-12-13 20:40:54 +00:00
# Optional options appended to `git-commit`
# See https://git-scm.com/docs/git-commit for a list of available options
commit_options : '--no-verify --signoff'
# Optional: Disable dirty check and always try to create a commit and push
skip_dirty_check : true
- name : Create PR
run : |
2022-10-10 14:28:19 +00:00
echo ${{ secrets.FLATHUB_TOKEN }} >> auth.txt
2020-12-13 20:40:54 +00:00
gh auth login --with-token < auth.txt
rm auth.txt
2021-01-15 20:34:14 +00:00
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."