forked from CrazyLegsSteph/ShortCommands
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d505068
commit 62b71ec
Showing
6 changed files
with
400 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: CI | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the main branch | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: windows-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: microsoft/setup-msbuild@v1.0.0 | ||
with: | ||
vs-version: 16.5 | ||
|
||
- uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax | ||
|
||
|
||
- name: Bootstrap | ||
run: python bootstrap.py | ||
timeout-minutes: 3 | ||
|
||
- name: Build Release | ||
run: MsBuild ShortCommands.sln /t:Build /p:Configuration=Release | ||
timeout-minutes: 5 | ||
|
||
- name: Build Debug | ||
run: MsBuild ShortCommands.sln /t:Build /p:Configuration=Debug | ||
timeout-minutes: 5 | ||
|
||
- name: Install python deps | ||
run: python -m pip install --user requests | ||
timeout-minutes: 5 | ||
|
||
- name: Run integration python test script | ||
run: python tests.py | ||
timeout-minutes: 20 | ||
|
||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Release Build | ||
path: ShortCommands/bin/Release/ShortCommands.* | ||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Debug Build | ||
path: ShortCommands/bin/Debug/ShortCommands.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: CI | ||
|
||
# Controls when the action will run. Triggers the workflow on push or pull request | ||
# events but only for the master branch | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
|
||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | ||
jobs: | ||
# This workflow contains a single job called "build" | ||
build: | ||
# The type of runner that the job will run on | ||
runs-on: windows-latest | ||
|
||
# Steps represent a sequence of tasks that will be executed as part of the job | ||
steps: | ||
|
||
- name: Extract tag name | ||
id: tag | ||
uses: actions/github-script@0.2.0 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
return context.payload.ref.replace(/\/refs\/tags\//, ''); | ||
- name: Echo tag | ||
run: echo ${{ steps.tag.outputs.result }} | ||
|
||
|
||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
|
||
- uses: microsoft/setup-msbuild@v1.0.0 | ||
with: | ||
vs-version: 16.5 | ||
|
||
- uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel | ||
|
||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax | ||
|
||
|
||
- name: Bootstrap | ||
run: python bootstrap.py | ||
timeout-minutes: 3 | ||
|
||
- name: Prepare Release | ||
run: python prepare_release.py ${{ steps.tag.outputs.result }} | ||
|
||
- name: Build Release | ||
run: MsBuild ShortCommands.sln /t:Build /p:Configuration=Release | ||
timeout-minutes: 5 | ||
|
||
- name: Install python deps | ||
run: python -m pip install --user requests | ||
timeout-minutes: 5 | ||
|
||
- name: Run integration python test script | ||
run: python tests.py | ||
timeout-minutes: 20 | ||
|
||
|
||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Release Build | ||
path: ShortCommands/bin/Release/ShortCommands.* | ||
|
||
- 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: true | ||
prerelease: false | ||
|
||
- name: Upload Release Asset | ||
id: 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: ./ShortCommands/bin/Release/ShortCommands.dll | ||
asset_name: ShortCommands.dll | ||
asset_content_type: "application/octet-stream" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import subprocess | ||
import os | ||
import sys | ||
from pathlib import Path | ||
import urllib.request | ||
import zipfile | ||
import io | ||
import shutil | ||
import shlex | ||
import re | ||
from typing import Optional, Union, Collection, Set | ||
|
||
OptionalPath = Union[None, Path, str] | ||
|
||
|
||
def download_tshock(url=r"https://github.com/Pryaxis/TShock/releases/download/v4.4.0-pre11/TShock4.4.0_Pre11_Terraria1.4.0.5.zip", dest: OptionalPath=None): | ||
if dest is None: | ||
dest = "./TShock" | ||
dest: Path = Path(dest) | ||
with urllib.request.urlopen(url) as response: | ||
buff = io.BytesIO() | ||
shutil.copyfileobj(response, buff) | ||
buff.seek(0) | ||
with zipfile.ZipFile(buff) as zf: | ||
dest.mkdir(exist_ok=True) | ||
zf.extractall(dest) | ||
|
||
if __name__ == "__main__": | ||
download_tshock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import sys | ||
import re | ||
from pathlib import Path | ||
import datetime | ||
|
||
def update_assembly_info(path: Path, version: str, encoding='utf-8'): | ||
content = path.read_text(encoding=encoding) | ||
content = re.sub(r"""^s*\[\s*assembly\s*:\s*AssemblyVersion\s*\(*.*\)\s*\]\s*$""", f'''[assembly: AssemblyVersion("{version}")]''', content, flags=re.MULTILINE | re.IGNORECASE) | ||
content = re.sub(r"""^s*\[\s*assembly\s*:\s*AssemblyFileVersion\s*\(*.*\)\s*\]\s*$""", f'''[assembly: AssemblyFileVersion("{version}")]''', content, flags=re.MULTILINE | re.IGNORECASE) | ||
path.write_text(content, encoding=encoding) | ||
|
||
|
||
def update_assemblies(version: str): | ||
for path in Path().glob("**/AssemblyInfo.cs"): | ||
update_assembly_info(path, version) | ||
|
||
|
||
if __name__ == "__main__": | ||
version = sys.argv[1] | ||
if version.startswith("refs/tags/"): | ||
version = version[len("refs/tags/"):] | ||
version = version.lstrip("v") | ||
version = tuple(int(n) for n in version.split(".")) | ||
if len(version) < 4: | ||
version = version + (0,) * (4 - len(version)) | ||
version = ".".join(map(str, version)) | ||
update_assemblies(version) |
Oops, something went wrong.