Skip to content

feat: remember FTP column size, close #640 #314

feat: remember FTP column size, close #640

feat: remember FTP column size, close #640 #314

name: Build/Publish on push
on:
push:
branches:
- "*dev*"
- "*master*"
- "*main*"
tags:
- "*"
jobs:
JobBuild:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
name: build_and_release
runs-on: windows-latest
if: |
!contains(github.event.head_commit.message, 'WIP')
env:
configuration: Release
Main_Project: Ui/Ui.csproj
Action_Url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Echo
shell: pwsh
run: |
echo "url = $env:Action_Url"
echo "home = $HOME"
echo "github.ref = ${{ github.ref }}"
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
# Install the .NET Core workload https://github.com/actions/setup-dotnet
- name: Install .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.1
# cache nuget packages: https://github.com/actions/cache
- name: Cache nuget packages
id: cache-nuget-packages
uses: actions/cache@v3
with:
path: ${{ github.workspace }}\.nuget\packages
key: ${{ runner.os }}-nuget-${{ hashFiles('Ui/Ui.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Cache nuget packages home
id: cache-nuget-packages-home
uses: actions/cache@v3
with:
path: C:\Users\runneradmin\.nuget\packages
key: ${{ runner.os }}-nuget-home-${{ hashFiles('Ui/Ui.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-home
# Restore nuget packages
- name: Restore nuget packages 📦️
run: msbuild $env:Main_Project /t:Restore /p:Configuration=$env:Configuration
# Run script
- name: Run script
shell: pwsh
run: |
./scripts/Set-Secret.ps1 -filePath .\Ui\Assert.cs -Pattern "===REPLACE_ME_WITH_APP_CENTER_SECRET===" -Secret ${{ secrets.APP_CENTER_SECRET_1REMOTE }}
./scripts/Set-Secret.ps1 -filePath .\Ui\Assert.cs -Pattern "===REPLACE_ME_WITH_SALT===" -Secret ${{ secrets.GLOBAL_STRING_ENCRYPTION_SLAT }}
# Get ${{env.BuildVersion}} and ${{env.PreRelease}}
- name: Get Version
id: get_version
run: ./scripts/Get-Version.ps1
# echo ${{env.BuildVersion}} and ${{env.PreRelease}}
- name: Echo Version
shell: pwsh
if: ${{env.PreRelease}} != ""
run: |
echo ${{env.BuildVersion}}
echo ${{env.PreRelease}}
## Publish the application Net4.8
#- name: Publish the application Net4.8
# run: dotnet publish $env:Main_Project -p:PublishProfile=./Ui/Properties/PublishProfiles/x64-net48.pubxml
# # run: msbuild $env:Main_Project -t:rebuild -verbosity:diag -property:Configuration=ReleaseNet48
## artifact
#- uses: actions/upload-artifact@v3
# with:
# name: 1Remote-${{env.BuildVersion}}-net4.8(not recommended)
# path: Ui/bin/Release/net4.8-windows/publish
# Publish the application Net6.0
- name: Publish the application
run: dotnet publish $env:Main_Project -p:PublishProfile=./Ui/Properties/PublishProfiles/x64-single.file.application.pubxml
# artifact
- uses: actions/upload-artifact@v3
with:
name: 1Remote-${{env.BuildVersion}}-net6-x64
path: Ui/bin/Release/net6.0-windows/publish/win-x64
outputs:
BuildVersion: ${{env.BuildVersion}}
PreRelease: ${{env.PreRelease}}
# artifact_net48: 1Remote-${{env.BuildVersion}}-net4.8(not recommended)
artifact_net6x: 1Remote-${{env.BuildVersion}}-net6-x64
# publish stable build, run only tag is not empty
StableRelease:
name: Stable publish
runs-on: ubuntu-latest
needs: JobBuild
if: |
startsWith(github.ref, 'refs/tags/') &&
needs.JobBuild.outputs.PreRelease == '' &&
!contains(github.event.head_commit.message, 'WIP')
steps:
- name: Echo
run: |
echo ${{needs.JobBuild.outputs.BuildVersion}}
echo ${{needs.JobBuild.outputs.PreRelease}}
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
# download artifact net6.x
- uses: actions/download-artifact@v2
with:
name: ${{needs.JobBuild.outputs.artifact_net6x}}
path: ${{needs.JobBuild.outputs.artifact_net6x}}
# zip
- name: Easy Zip Files
uses: vimtor/action-zip@v1
with:
files: ${{needs.JobBuild.outputs.artifact_net6x}}
dest: ${{needs.JobBuild.outputs.artifact_net6x}}.zip
## download artifact net4.8
#- uses: actions/download-artifact@v2
# with:
# name: ${{needs.JobBuild.outputs.artifact_net48}}
# path: ${{needs.JobBuild.outputs.artifact_net48}}
## zip
#- name: Easy Zip Files
# uses: vimtor/action-zip@v1
# with:
# files: ${{needs.JobBuild.outputs.artifact_net48}}
# dest: ${{needs.JobBuild.outputs.artifact_net48}}.zip
# make release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
# upload package net6.x
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{needs.JobBuild.outputs.artifact_net6x}}.zip
asset_name: ${{needs.JobBuild.outputs.artifact_net6x}}.zip
asset_content_type: application/zip
## upload package net4.8
#- name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ${{needs.JobBuild.outputs.artifact_net48}}.zip
# asset_name: ${{needs.JobBuild.outputs.artifact_net48}}.zip
# asset_content_type: application/zip
# set changelogs
- uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npx changelogithub #--draft #--prerelease # or changelogithub@0.12 if ensure the stable result
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
PreRelease:
name: pre-release publish
runs-on: ubuntu-latest
needs: JobBuild
if: |
startsWith(github.ref, 'refs/tags/') &&
needs.JobBuild.outputs.PreRelease != '' &&
!contains(github.event.head_commit.message, 'WIP')
steps:
- name: Echo
run: |
echo ${{needs.JobBuild.outputs.BuildVersion}}
echo ${{needs.JobBuild.outputs.PreRelease}}
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: recursive
# download artifact net6.x
- uses: actions/download-artifact@v2
with:
name: ${{needs.JobBuild.outputs.artifact_net6x}}
path: ${{needs.JobBuild.outputs.artifact_net6x}}
# zip
- name: Easy Zip Files
uses: vimtor/action-zip@v1
with:
files: ${{needs.JobBuild.outputs.artifact_net6x}}
dest: ${{needs.JobBuild.outputs.artifact_net6x}}.zip
## download artifact net4.8
#- uses: actions/download-artifact@v2
# with:
# name: ${{needs.JobBuild.outputs.artifact_net48}}
# path: ${{needs.JobBuild.outputs.artifact_net48}}
## zip
#- name: Easy Zip Files
# uses: vimtor/action-zip@v1
# with:
# files: ${{needs.JobBuild.outputs.artifact_net48}}
# dest: ${{needs.JobBuild.outputs.artifact_net48}}.zip
# make release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true
# upload package net6.x
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ${{needs.JobBuild.outputs.artifact_net6x}}.zip
asset_name: ${{needs.JobBuild.outputs.artifact_net6x}}.zip
asset_content_type: application/zip
## upload package net4.8
#- name: Upload Release Asset
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ${{needs.JobBuild.outputs.artifact_net48}}.zip
# asset_name: ${{needs.JobBuild.outputs.artifact_net48}}.zip
# asset_content_type: application/zip
# set changelogs
- uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npx changelogithub --prerelease #--draft #--prerelease # or changelogithub@0.12 if ensure the stable result
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
# publish nightly build
NightlyRelease:
name: Nightly publish
runs-on: ubuntu-latest
needs: JobBuild
if: |
!startsWith(github.ref, 'refs/tags/') &&
!startsWith(github.event.head_commit.message, 'chore:') &&
!contains(github.event.head_commit.message, 'WIP')
steps:
- name: Echo
run: |
echo ${{needs.JobBuild.outputs.BuildVersion}}
echo ${{needs.JobBuild.outputs.PreRelease}}
# download artifact net6.x
- uses: actions/download-artifact@v2
with:
name: ${{needs.JobBuild.outputs.artifact_net6x}}
path: ${{needs.JobBuild.outputs.artifact_net6x}}
# zip
- uses: vimtor/action-zip@v1
with:
files: ${{needs.JobBuild.outputs.artifact_net6x}}
dest: ${{needs.JobBuild.outputs.artifact_net6x}}.zip
# for 1Remote project
# publish nightly with WebFreak001/deploy-nightly@v2.0.0
- uses: WebFreak001/deploy-nightly@v2.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # automatically provided by github actions
with:
upload_url: https://uploads.github.com/repos/1Remote/1Remote/releases/96075099/assets{?name,label} # find out this value by opening https://api.github.com/repos/<owner>/<repo>/releases in your browser and copy the full "upload_url" value including the {?name,label} part
release_id: 96075099 # same as above (id can just be taken out the upload_url, it's used to find old releases)
asset_path: ${{needs.JobBuild.outputs.artifact_net6x}}.zip # path to archive to upload
asset_name: ${{needs.JobBuild.outputs.artifact_net6x}}-nightly-$$.zip # name to upload the release as, use $$ to insert date (YYYYMMDD) and 6 letter commit hash
asset_content_type: application/zip # required by GitHub API
max_releases: 10 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted