Skip to content

Merge pull request #110 from goatcorp/fix-release-ci #12

Merge pull request #110 from goatcorp/fix-release-ci

Merge pull request #110 from goatcorp/fix-release-ci #12

Workflow file for this run

name: "Release XLCore"
on:
push:
tags:
- "*.*.*"
permissions:
contents: write
jobs:
Release:
if: github.repository == 'goatcorp/XIVLauncher.Core'
runs-on: ubuntu-latest
env:
# These are the user credentials that will be used to make the PR.
COMMIT_USER: github-actions[bot]
COMMIT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
# Where the changes will be made.
HEAD_BRANCH: xlcore-${{ github.ref_name }}
# Where the PR will be made to.
BASE_REPO: flathub/dev.goats.xivlauncher
BASE_BRANCH: master
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Setup Commit Author
run: |
git config --global user.name $COMMIT_USER
git config --global user.email $COMMIT_EMAIL
git config --global pull.rebase false
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x # Set this to be the same as the projects required dotnet version.
- name: Setup Python3
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Setup Flatpak
run: |
sudo apt update -y
sudo apt install flatpak -y
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install --user org.freedesktop.Sdk.Extension.dotnet6/x86_64/22.08 -y # Update this when needed.
flatpak install --user org.freedesktop.Sdk/x86_64/22.08 -y # As well as this, if dependency generation is failing.
- name: Dotnet Restore
working-directory: ./src/XIVLauncher.Core/
run: dotnet restore
- name: Dotnet Build (Default)
working-directory: ./src/XIVLauncher.Core/
run: dotnet publish -r linux-x64 --sc --configuration Release --no-restore -o ./dist/XIVLauncher.Core
- name: Dotnet Build (Arch)
working-directory: ./src/XIVLauncher.Core/
run: dotnet publish -r linux-x64 --sc --configuration Release -p:DefineConstants=WINE_XIV_ARCH_LINUX --no-restore -o ./dist/XIVLauncher.Core-arch
- name: Dotnet Build (Fedora)
working-directory: ./src/XIVLauncher.Core/
run: dotnet publish -r linux-x64 --sc --configuration Release -p:DefineConstants=WINE_XIV_FEDORA_LINUX --no-restore -o ./dist/XIVLauncher.Core-fedora
- name: Dotnet Build (Windows)
working-directory: ./src/XIVLauncher.Core/
run: dotnet publish -r win10-x64 --sc --configuration Release -o ./dist/XIVLauncher.Core-win10x64
- name: Generate nuget-dependencies.json
working-directory: ./src/XIVLauncher.Core/
run: |
curl -LO https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/dotnet/flatpak-dotnet-generator.py
python3 flatpak-dotnet-generator.py nuget-dependencies.json XIVLauncher.Core.csproj
- name: Upload nuget-dependencies.json
uses: actions/upload-artifact@v3
with:
name: nuget-dependencies
path: |
./src/XIVLauncher.Core/nuget-dependencies.json
- name: Make PR to Flatpak repository
run: |
# Authenticate with GitHub CLI.
echo ${{ secrets.PUSH_TOKEN }} | gh auth login --with-token
# Clone the repository we want to make the PR to.
gh repo fork ${{ env.BASE_REPO }} --clone=true --remote=true /tmp/xlcore-flatpak
# Sync the main branch & create a new branch for the PR
git -C /tmp/xlcore-flatpak fetch upstream
git -C /tmp/xlcore-flatpak reset --hard && git -C /tmp/xlcore-flatpak clean -fdx
git -C /tmp/xlcore-flatpak pull upstream master
# Delete (if exists) and create the branch we want to make the PR from.
git -C /tmp/xlcore-flatpak branch -D ${{ env.HEAD_BRANCH }} || true
git -C /tmp/xlcore-flatpak checkout -b ${{ env.HEAD_BRANCH }}
# Copy the files we need to the forked repository.
cp ./src/XIVLauncher.Core/nuget-dependencies.json /tmp/xlcore-flatpak/
cp ./.github/scripts/update_flatpak_manifest.py /tmp/xlcore-flatpak/
# Update the manifest.
cd /tmp/xlcore-flatpak
python3 -m pip install pyyaml
python3 update_flatpak_manifest.py dev.goats.xivlauncher.yml dev.goats.xivlauncher.appdata.xml ${{ github.ref_name }} ${{ github.sha }}
rm update_flatpak_manifest.py
# Commit the changes.
git add .
git commit -m "Update to ${{ github.ref_name }}"
# Get the remote url and splice the token into it.
REMOTE_URL=$(git remote get-url origin)
REMOTE_URL=${REMOTE_URL/https:\/\//https:\/\/${{ secrets.PUSH_TOKEN }}@}
git remote set-url origin $REMOTE_URL
# Push the changes to the fork.
git remote -v
git push --set-upstream origin ${{ env.HEAD_BRANCH }} --force
# Make a PR from the fork to the upstream repository.
gh pr create --repo ${{ env.BASE_REPO }} --title "Update to ${{ github.ref_name }}" --body "This PR was automatically generated by GitHub Actions."
- name: Compress release files
run: |
sudo apt install zip -y
mkdir -p ./dist
# remove leading directories
tar -czf ./dist/XIVLauncher.Core.tar.gz -C ./src/XIVLauncher.Core/dist/XIVLauncher.Core .
tar -czf ./dist/XIVLauncher.Core-arch.tar.gz -C ./src/XIVLauncher.Core/dist/XIVLauncher.Core-arch .
tar -czf ./dist/XIVLauncher.Core-fedora.tar.gz -C ./src/XIVLauncher.Core/dist/XIVLauncher.Core-fedora .
zip -r ./dist/XIVLauncher.Core-win10x64.zip ./src/XIVLauncher.Core/dist/XIVLauncher.Core-win10x64
- name: Release on GitHub
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
# body_path: .github/release_notices.md
# append_body: true # and this to make sure they are appended, not replacing the original.
files: |
./dist/XIVLauncher.Core.tar.gz
./dist/XIVLauncher.Core-arch.tar.gz
./dist/XIVLauncher.Core-fedora.tar.gz
./dist/XIVLauncher.Core-win10x64.zip