Skip to content

Commit

Permalink
Merge pull request #85 from WeihanLi/dev
Browse files Browse the repository at this point in the history
0.9.0
  • Loading branch information
WeihanLi authored Dec 2, 2024
2 parents f7a1ae4 + 2f513a2 commit 093b033
Show file tree
Hide file tree
Showing 45 changed files with 262 additions and 383 deletions.
49 changes: 22 additions & 27 deletions .azure/pipelines/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ trigger:
include:
- 'main'
- 'preview'
- 'dev'

pool:
vmImage: 'ubuntu-latest'
Expand All @@ -11,39 +12,33 @@ variables:
- group: docker

steps:
- task: UseDotNet@2
displayName: 'Use .NET 6 sdk'
inputs:
packageType: sdk
version: 6.0.x
- task: UseDotNet@2
displayName: 'Use .NET 7 sdk'
inputs:
packageType: sdk
version: 7.0.x
- task: UseDotNet@2
displayName: 'Use .NET 8 sdk'
inputs:
packageType: sdk
version: 8.0.x
includePreviewVersions: true # Required for preview versions

- script: dotnet restore
displayName: "dotnet restore"
- script: dotnet build -c Release
displayName: "dotnet build"

- script: docker build -f Dockerfile -t weihanli/dotnet-httpie:latest -t weihanli/dotnet-httpie:preview -t weihanli/dotnet-httpie:stable .
- script: |
docker login -u $(dockerId) -p $(pswd)
displayName: 'Docker login'

- script: |
docker version
docker buildx version
# docker run --privileged --rm tonistiigi/binfmt --install all
docker run --privileged --rm multiarch/qemu-user-static --reset -p yes
docker buildx create --name container-builder --driver docker-container --driver-opt default-load=true --bootstrap --use
displayName: 'Setup qemu and docker buildx'

- script: |
docker buildx build --push -f Dockerfile --platform="linux/amd64,linux/arm64" --output="type=image" -t weihanli/dotnet-httpie:latest .
displayName: 'Docker build Script'

- script: |
docker login -u $(dockerId) -p $(pswd)
docker push weihanli/dotnet-httpie:preview
docker buildx build --push -f Dockerfile --platform="linux/amd64,linux/arm64" --output="type=image" -t weihanli/dotnet-httpie:preview .
displayName: 'Push preview image'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/preview'))

- script: |
docker login -u $(dockerId) -p $(pswd)
docker push weihanli/dotnet-httpie:stable
docker buildx build --push -f Dockerfile --platform="linux/amd64,linux/arm64" --output="type=image" -t weihanli/dotnet-httpie:stable .
displayName: 'Push stable image'
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))

- script: |
docker logout
displayName: 'Docker logout'
condition: always()
26 changes: 7 additions & 19 deletions .azure/pipelines/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,16 @@ variables:

steps:
- task: UseDotNet@2
displayName: 'Use .NET 6 sdk'
displayName: 'Use .NET SDK'
inputs:
packageType: sdk
version: 6.0.x
- task: UseDotNet@2
displayName: 'Use .NET 7 sdk'
inputs:
packageType: sdk
version: 7.0.x
- task: UseDotNet@2
displayName: 'Use .NET 8 sdk'
inputs:
packageType: sdk
version: 8.0.x
includePreviewVersions: true # Required for preview versions

- script: dotnet --info
version: 9.0.x
# includePreviewVersions: true # Required for preview versions
- script: |
dotnet tool install -g dotnet-execute
dotnet-exec info
dotnet --info
displayName: "dotnet info"
- script: dotnet restore
displayName: "dotnet restore"
- script: dotnet build -c Release
displayName: "dotnet build"
- powershell: ./build.ps1
displayName: 'Powershell Script'
env:
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand All @@ -51,12 +51,9 @@ jobs:
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
dotnet-version: 9.0.x
# include-prerelease: true
- name: dotnet info
run: dotnet --info
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/dotnet-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
include-prerelease: true
dotnet-version: 9.0.x
- name: dotnet info
run: dotnet --info
- name: build
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/dotnet-outdated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
include-prerelease: true
dotnet-version: 9.0.x
- name: dotnet info
run: dotnet --info
- name: build
Expand Down
27 changes: 9 additions & 18 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ jobs:
mac-build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
dotnet-version: 9.0.x
- name: dotnet info
run: dotnet --info
- name: build
Expand All @@ -30,14 +27,11 @@ jobs:
linux-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
dotnet-version: 9.0.x
- name: dotnet info
run: dotnet --info
- name: build
Expand All @@ -46,14 +40,11 @@ jobs:
windows-build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
dotnet-version: 9.0.x
- name: dotnet info
run: dotnet --info
- name: build
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ jobs:
runs-on: windows-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
7.0.x
8.0.x
dotnet-version: 9.0.x
- name: dotnet info
run: dotnet --info

- name: Create Github release
run: |
dotnet --info
dotnet tool install -g dotnet-execute
dotnet-exec info
- name: Export Release Version
run: dotnet-exec https://github.com/OpenReservation/scripts/blob/main/build/export-gh-release-version.cs
- name: Create Github Release
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./build.ps1 --stable=true
$VERSION = Get-ChildItem -Path artifacts/packages/*.nupkg -Name | Select-String -Pattern '\d+.\d+.\d+' | foreach {$_.Matches.Value}
gh release create --generate-notes $VERSION
gh release create ${{ env.ReleaseVersion }} --generate-notes
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# customize files
out/
8 changes: 7 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
<Product>dotnet-httpie</Product>
<Authors>WeihanLi</Authors>
<Copyright>Copyright 2021-$([System.DateTime]::Now.Year) (c) WeihanLi</Copyright>
<NoWarn>NU1507;</NoWarn>
<NoWarn>$(NoWarn);NU1507;</NoWarn>
</PropertyGroup>
<PropertyGroup>
<!-- https://learn.microsoft.com/en-us/nuget/concepts/auditing-packages -->
<NuGetAudit>true</NuGetAudit>
<NuGetAuditMode>direct</NuGetAuditMode>
<NuGetAuditLevel>high</NuGetAuditLevel>
</PropertyGroup>
<ItemGroup>
<Using Include="WeihanLi.Common"/>
Expand Down
29 changes: 11 additions & 18 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,19 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="JsonPath.Net" Version="0.6.7" />
<PackageVersion Include="JsonSchema.Net" Version="5.3.1" />
<PackageVersion Include="JsonPath.Net" Version="1.1.6" />
<PackageVersion Include="JsonSchema.Net" Version="7.2.3" />
<PackageVersion Include="MathNet.Numerics.Signed" Version="5.0.0" />
<PackageVersion Condition="'$(TargetFramework)'=='net6.0'" Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageVersion Condition="'$(TargetFramework)'=='net7.0'" Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageVersion Condition="'$(TargetFramework)'=='net8.0'" Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="WeihanLi.Common" Version="1.0.60" />
<PackageVersion Include="WeihanLi.Npoi" Version="2.4.2" />
<PackageVersion Include="WeihanLi.Common" Version="1.0.72" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Moq" Version="4.20.69" />
<PackageVersion Include="xunit" Version="2.6.4" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.6" />
<PackageVersion Include="Xunit.DependencyInjection" Version="8.9.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Xunit.DependencyInjection" Version="9.7.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="PolySharp" Version="1.13.2" />
</ItemGroup>
</Project>
</Project>
43 changes: 32 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
FROM mcr.microsoft.com/dotnet/runtime-deps:8.0-alpine AS base
LABEL Maintainer="WeihanLi"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net9.0-cross-arm64-musl AS cross-build-env

FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build-env
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build-env

# Install NativeAOT build prerequisites
# RUN apk update && apk add clang gcc lld musl-dev build-base zlib-dev
COPY --from=cross-build-env /crossrootfs /crossrootfs

ARG TARGETARCH
ARG BUILDARCH

# Configure NativeAOT Build Prerequisites
# https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/?tabs=linux-alpine%2Cnet8
# for alpine
RUN apk update && apk add clang build-base zlib-dev
# for debian/ubuntu
# RUN apt-get update && apt-get install -y clang zlib1g-dev

WORKDIR /app

COPY ./src/ ./src/
COPY ./build/ ./build/
COPY ./Directory.Build.props ./
COPY ./Directory.Build.targets ./
COPY ./Directory.Packages.props ./
COPY ./.editorconfig ./

WORKDIR /app/src/HTTPie/
RUN dotnet publish -f net8.0 -c Release --self-contained --use-current-runtime -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -p:AssemblyName=http -p:TargetFrameworks=net8.0 -o /app/artifacts

FROM base AS final
COPY --from=build-env /app/artifacts/http /root/.dotnet/tools/http
RUN ln -s /root/.dotnet/tools/http /root/.dotnet/tools/dotnet-http
ENV PATH="/root/.dotnet/tools:${PATH}"
ENTRYPOINT ["http"]
RUN if [ "${TARGETARCH}" = "${BUILDARCH}" ]; then \
dotnet publish -f net9.0 --use-current-runtime -p:AssemblyName=http -p:TargetFrameworks=net9.0 -o /app/artifacts; \
else \
apk add binutils-aarch64 --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community; \
dotnet publish -f net9.0 -r linux-musl-arm64 -p:AssemblyName=http -p:TargetFrameworks=net9.0 -p:SysRoot=/crossrootfs/arm64 -p:ObjCopyName=aarch64-alpine-linux-musl-objcopy -o /app/artifacts; \
fi

FROM alpine

# https://github.com/opencontainers/image-spec/blob/main/annotations.md
LABEL org.opencontainers.image.authors="WeihanLi"
LABEL org.opencontainers.image.source="https://github.com/WeihanLi/dotnet-httpie"

COPY --from=build-env /app/artifacts/http /usr/bin/http
RUN chmod +x /usr/bin/http
ENTRYPOINT ["/usr/bin/http"]
CMD ["--help"]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[![Github Actions Build Status](https://github.com/WeihanLi/dotnet-HTTPie/workflows/default/badge.svg?branch=dev)](https://github.com/WeihanLi/dotnet-HTTPie/actions?query=workflow%default+branch%3Adev)

[![Docker Pulls](https://img.shields.io/docker/pulls/weihanli/dotnet-httpie)](https://hub.docker.com/r/weihanli/dotnet-httpie)
[![Docker Pulls](https://img.shields.io/docker/pulls/weihanli/dotnet-httpie)](https://hub.docker.com/r/weihanli/dotnet-httpie/tags)

## Intro

Expand Down Expand Up @@ -83,13 +83,13 @@ see http request sample here: <https://github.com/WeihanLi/dotnet-httpie/tree/de
There's a docker image(weihanli/dotnet-httpie) that you could use directly without installing the tool, use sample:

``` bash
docker run --rm --pull=always weihanli/dotnet-httpie:latest http -v github.com
docker run --rm --pull=always weihanli/dotnet-httpie:latest -v github.com

docker run --rm --pull=always weihanli/dotnet-httpie:latest http reservation.weihanli.xyz/health job:='{"id":1,"name":"tester"}' --offline
docker run --rm --pull=always weihanli/dotnet-httpie:latest reservation.weihanli.xyz/health job:='{"id":1,"name":"tester"}' --offline

docker run --rm --pull=always weihanli/dotnet-httpie:latest http PUT httpbin.org hello=world
docker run --rm --pull=always weihanli/dotnet-httpie:latest PUT httpbin.org hello=world

docker run --rm --pull=always weihanli/dotnet-httpie:latest http get httpbin.org/status/400
docker run --rm --pull=always weihanli/dotnet-httpie:latest get httpbin.org/status/400
```

## More
Expand Down
Loading

0 comments on commit 093b033

Please sign in to comment.