diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..e8570d7 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,56 @@ +name: build + +on: + push: + branches: + - "**" + tags: + - "v*" + +jobs: + build: + runs-on: debian + strategy: + matrix: + include: + - goarch: amd64 + output: docker-compose-backup-linux-amd64 + - goarch: arm64 + output: docker-compose-backup-linux-arm64 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.26" + + - name: Build ${{ matrix.output }} + env: + CGO_ENABLED: "0" + GOOS: linux + GOARCH: ${{ matrix.goarch }} + run: | + if [ "${GITHUB_REF_TYPE}" = "tag" ]; then + VERSION="${GITHUB_REF_NAME}" + else + VERSION="${GITHUB_REF_NAME}-${GITHUB_SHA::7}" + fi + go build -trimpath \ + -ldflags "-s -w -X git.misaka.ren/M1saka/docker_backup/cmd/backup.Version=${VERSION}" \ + -o "${{ matrix.output }}" . + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.output }} + path: ${{ matrix.output }} + + - name: Attach to release + if: startsWith(github.ref, 'refs/tags/v') + uses: akkuman/gitea-release-action@v1 + with: + files: ${{ matrix.output }} + env: + NODE_OPTIONS: "--experimental-fetch"