diff --git a/.github/workflows/build-master.yml b/.github/workflows/build-master.yml deleted file mode 100644 index 69fb231..0000000 --- a/.github/workflows/build-master.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Build master - -on: - push: - branches: - - 'master' - tags-ignore: - - 'v*' - -jobs: - - build: - name: Build - runs-on: ubuntu-latest - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - - steps: - - - name: Check out - uses: actions/checkout@v3 - - - name: Get time - uses: gerred/actions/current-time@master - id: current-time - - - name: Build - uses: tobyxdd/go-cross-build@d00fc41eb205f57dd90f6e5af4613e21c7ebe73f - env: - TIME: "${{ steps.current-time.outputs.time }}" - GOFLAGS: "-tags=gpl" - CGO_ENABLED: "0" - with: - name: hysteria - dest: dist - ldflags: -w -s -X main.appCommit=${{ github.sha }} -X main.appDate=${{ env.TIME }} - platforms: 'darwin/amd64, darwin/arm64, windows/amd64, windows/386, linux/amd64, linux/386, linux/arm, linux/arm64, linux/s390x, linux/mipsle, freebsd/amd64, freebsd/386, freebsd/arm, freebsd/arm64' - package: cmd - compress: false - - - name: Archive - uses: actions/upload-artifact@v3 - with: - name: dist - path: dist diff --git a/.github/workflows/dev-build-master.yml b/.github/workflows/dev-build-master.yml new file mode 100644 index 0000000..5e447d9 --- /dev/null +++ b/.github/workflows/dev-build-master.yml @@ -0,0 +1,38 @@ +name: "Build master" + +on: + push: + branches: + - 'master' + tags-ignore: + - 'v*' + +jobs: + + build: + name: Build + runs-on: ubuntu-latest + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + + steps: + + - name: Check out + uses: actions/checkout@v3 + + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Run build script + env: + HY_APP_PLATFORMS: 'darwin/amd64,darwin/arm64,windows/amd64,windows/386,linux/amd64,linux/386,linux/arm,linux/arm64,linux/s390x,linux/mipsle,freebsd/amd64,freebsd/386,freebsd/arm,freebsd/arm64' + run: ./build.sh + shell: bash + + - name: Archive + uses: actions/upload-artifact@v3 + with: + name: hysteria-binaries-${{ github.sha }} + path: ./build diff --git a/.github/workflows/docker.yaml b/.github/workflows/release-docker.yaml similarity index 83% rename from .github/workflows/docker.yaml rename to .github/workflows/release-docker.yaml index 85d6198..b27ed6a 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/release-docker.yaml @@ -16,8 +16,8 @@ jobs: uses: actions/checkout@v3 - name: Get tag - uses: olegtarasov/get-tag@v2 - id: tagName + id: get_tag + run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -38,7 +38,7 @@ jobs: context: . push: true platforms: linux/amd64,linux/arm64 - tags: tobyxdd/hysteria:latest,tobyxdd/hysteria:${{ env.GIT_TAG_NAME }} + tags: tobyxdd/hysteria:latest,tobyxdd/hysteria:${{ steps.get_tag.outputs.tag }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1e5f557..f19e94e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,31 +18,20 @@ jobs: - name: Check out uses: actions/checkout@v3 - - name: Get tag - uses: olegtarasov/get-tag@v2 - id: tagName - - - name: Get time - uses: gerred/actions/current-time@master - id: current-time - - - name: Build - uses: tobyxdd/go-cross-build@d00fc41eb205f57dd90f6e5af4613e21c7ebe73f - env: - TIME: "${{ steps.current-time.outputs.time }}" - GOFLAGS: "-tags=gpl" - CGO_ENABLED: "0" + - name: Setup Go + uses: actions/setup-go@v3 with: - name: hysteria - dest: dist - ldflags: -w -s -X main.appVersion=${{ env.GIT_TAG_NAME }} -X main.appCommit=${{ github.sha }} -X main.appDate=${{ env.TIME }} - platforms: 'darwin/amd64, darwin/arm64, windows/amd64, windows/386, linux/amd64, linux/386, linux/arm, linux/arm64, linux/s390x, linux/mipsle, freebsd/amd64, freebsd/386, freebsd/arm, freebsd/arm64' - package: cmd - compress: false + go-version: 1.19 + + - name: Run build script + env: + HY_APP_PLATFORMS: 'darwin/amd64,darwin/arm64,windows/amd64,windows/386,linux/amd64,linux/386,linux/arm,linux/arm64,linux/s390x,linux/mipsle,freebsd/amd64,freebsd/386,freebsd/arm,freebsd/arm64' + run: ./build.sh + shell: bash - name: Generate hashes run: | - cd dist + cd build for f in $(find . -type f); do sha256sum $f | sudo tee -a hashes.txt done @@ -52,18 +41,18 @@ jobs: if: startsWith(github.ref, 'refs/tags/') with: files: | - ./dist/hysteria-darwin-amd64 - ./dist/hysteria-darwin-arm64 - ./dist/hysteria-windows-amd64.exe - ./dist/hysteria-windows-386.exe - ./dist/hysteria-linux-amd64 - ./dist/hysteria-linux-386 - ./dist/hysteria-linux-arm - ./dist/hysteria-linux-arm64 - ./dist/hysteria-linux-s390x - ./dist/hysteria-linux-mipsle - ./dist/hysteria-freebsd-amd64 - ./dist/hysteria-freebsd-386 - ./dist/hysteria-freebsd-arm - ./dist/hysteria-freebsd-arm64 - ./dist/hashes.txt + ./build/hysteria-darwin-amd64 + ./build/hysteria-darwin-arm64 + ./build/hysteria-windows-amd64.exe + ./build/hysteria-windows-386.exe + ./build/hysteria-linux-amd64 + ./build/hysteria-linux-386 + ./build/hysteria-linux-arm + ./build/hysteria-linux-arm64 + ./build/hysteria-linux-s390x + ./build/hysteria-linux-mipsle + ./build/hysteria-freebsd-amd64 + ./build/hysteria-freebsd-386 + ./build/hysteria-freebsd-arm + ./build/hysteria-freebsd-arm64 + ./build/hashes.txt diff --git a/Dockerfile b/Dockerfile index 41d3a94..496f634 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,17 +11,12 @@ ENV GOPROXY ${GOPROXY} COPY . /go/src/github.com/hynetwork/hysteria -WORKDIR /go/src/github.com/hynetwork/hysteria/cmd +WORKDIR /go/src/github.com/hynetwork/hysteria RUN set -ex \ && apk add git build-base \ - && export VERSION=$(git describe --tags) \ - && export COMMIT=$(git rev-parse HEAD) \ - && export TIMESTAMP=$(date "+%F %T") \ - && go build -trimpath -o /go/bin/hysteria -ldflags \ - "-w -s -X 'main.appVersion=${VERSION}' \ - -X 'main.appCommit=${COMMIT}' \ - -X 'main.appDate=${TIMESTAMP}'" + && ./build.sh \ + && mv ./build/hysteria-* /go/bin/hysteria # multi-stage builds to create the final image FROM alpine AS dist