Skip to content

Commit 2709214

Browse files
Merge pull request #1 from thinkbeforecoding/actions
setup github actions for CI
2 parents 29240d1 + 671784c commit 2709214

File tree

3 files changed

+109
-13
lines changed

3 files changed

+109
-13
lines changed

.github/workflows/build.yml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: .NET Core
2+
on:
3+
push:
4+
pull_request:
5+
release:
6+
types:
7+
- published
8+
env:
9+
# Stop wasting time caching packages
10+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
11+
# Disable sending usage data to Microsoft
12+
DOTNET_CLI_TELEMETRY_OPTOUT: true
13+
# Project name to pack and publish
14+
PROJECT_NAME: fasm
15+
# GitHub Packages Feed settings
16+
GITHUB_FEED: https://nuget.pkg.github.com/d-edge/
17+
GITHUB_USER: thinkbeforecoding
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
# Official NuGet Feed settings
20+
NUGET_FEED: https://api.nuget.org/v3/index.json
21+
NUGET_KEY: ${{ secrets.NUGET_KEY }}
22+
jobs:
23+
build:
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
matrix:
27+
os: [ ubuntu-latest, windows-latest, macos-latest ]
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
- name: Setup .NET Core
32+
uses: actions/setup-dotnet@v1
33+
with:
34+
dotnet-version: 5.0.300
35+
- name: Tool restore
36+
run: dotnet tool restore
37+
- name: Restore
38+
run: dotnet restore
39+
- name: Build
40+
run: dotnet build -c Release --no-restore
41+
- name: Test
42+
run: dotnet test -c Release
43+
- name: Pack
44+
if: matrix.os == 'ubuntu-latest'
45+
run: dotnet pack -v normal -c Release --no-restore -p:PackageVersion=$GITHUB_RUN_ID.0.0 src/$PROJECT_NAME/$PROJECT_NAME.fsproj -o bin/nuget
46+
- name: Upload Artifact
47+
if: matrix.os == 'ubuntu-latest'
48+
uses: actions/upload-artifact@v2
49+
with:
50+
name: nupkg
51+
path: ./bin/nuget/*.nupkg
52+
prerelease:
53+
needs: build
54+
if: github.ref == 'refs/heads/develop'
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Download Artifact
58+
uses: actions/download-artifact@v1
59+
with:
60+
name: nupkg
61+
- name: Push to GitHub Feed
62+
run: |
63+
for f in ./nupkg/*.nupkg
64+
do
65+
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
66+
done
67+
deploy:
68+
needs: build
69+
if: github.event_name == 'release'
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v2
73+
- name: Setup .NET Core
74+
uses: actions/setup-dotnet@v1
75+
with:
76+
dotnet-version: 5.0.300
77+
- name: Create Release NuGet package
78+
run: |
79+
arrTag=(${GITHUB_REF//\// })
80+
VERSION="${arrTag[2]}"
81+
echo Version: $VERSION
82+
VERSION="${VERSION//v}"
83+
echo Clean Version: $VERSION
84+
dotnet pack -v normal -c Release -p:PackageVersion=$VERSION -o nupkg src/$PROJECT_NAME/$PROJECT_NAME.fsproj
85+
- name: Push to GitHub Feed
86+
run: |
87+
for f in ./nupkg/*.nupkg
88+
do
89+
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
90+
done
91+
- name: Push to NuGet Feed
92+
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY

src/fasm/fasm.fsproj

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,25 @@
77
<ToolCommandName>fasm</ToolCommandName>
88
<PackageOutputPath>./nuget</PackageOutputPath>
99
<Authors>Jérémie Chassaing</Authors>
10+
<Company>D-Edge</Company>
1011
<Description>F# jit disassembler</Description>
11-
<Version>0.1.0</Version>
1212
<Copyright>Copyright (c) 2021 D-EDGE</Copyright>
1313
<RepositoryUrl>https://github.com/d-edge/fasm</RepositoryUrl>
1414
<RepositoryType>git</RepositoryType>
1515
<PackageType>DotNetCliTool</PackageType>
1616
<PackageIcon>fasm.png</PackageIcon>
17+
<PackageProjectUrl>https://github.com/d-edge/fasm</PackageProjectUrl>
18+
<RepositoryUrl>https://github.com/d-edge/fasm</RepositoryUrl>
1719
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1820
</PropertyGroup>
1921
<ItemGroup>
2022
<Compile Include="FileSystem.fs" />
2123
<Compile Include="Compilation.fs" />
2224
<Compile Include="Disassembly.fs" />
2325
<Compile Include="Program.fs" />
24-
<None Include="..\..\img\fasm.png" Pack="true" PackagePath=""/>
25-
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
26+
<None Include="..\..\img\fasm.png" Pack="true" PackagePath="" />
27+
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
28+
<None Include="paket.references" />
2629
</ItemGroup>
2730
<Import Project="..\..\.paket\Paket.Restore.targets" />
2831
</Project>

tests/fasm.tests/Tests.fs

+11-10
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ open FileSystem
66
open Xunit
77

88
// generated asm is platform sensitive due to differences in call conventions
9-
let isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
9+
let isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
1010

1111
// normalize line endings for string comparions
1212
let normalizeLineEnds (s: string) =
13-
if isLinux then
14-
s.Replace("\r\n", "\n")
15-
else
13+
if isWindows then
1614
s
15+
else
16+
s.Replace("\r\n", "\n")
1717

1818
module Assert =
1919
let EqualString(x, y) = Assert.Equal(normalizeLineEnds x, normalizeLineEnds y)
@@ -42,20 +42,21 @@ let ``check basic 'inc' method disassembly`` () =
4242
let output = disassembleFromSourceProject "inc"
4343

4444
let expected =
45-
if isLinux then
46-
// on linux, the argument is in rdi
45+
if isWindows then
46+
// on windows, the argument is in rcx
4747
"""
4848
;Source.inc(Int32)
49-
L0000: lea eax, [rdi+1]
49+
L0000: lea eax, [rcx+1]
5050
L0003: ret
5151
"""
52-
else
53-
// on windows, the argument is in rcx
52+
else
53+
// on linux, the argument is in rdi
5454
"""
5555
;Source.inc(Int32)
56-
L0000: lea eax, [rcx+1]
56+
L0000: lea eax, [rdi+1]
5757
L0003: ret
5858
"""
59+
5960
Assert.EqualString(expected, output)
6061

6162
[<Fact>]

0 commit comments

Comments
 (0)