Commit graph

78 commits

Author SHA1 Message Date
Francis Lavoie
661655cf05
Add support for setcap from build command (#129) 2023-02-06 13:26:33 -05:00
Matthew Holt
e0ed12b135
readme: Add pro tip about manual builds 2022-10-05 18:49:31 -06:00
Matthew Holt
2b5d89d9e5
Remove use of io/ioutil 2022-09-30 11:26:26 -06:00
Matthew Holt
e09becb9d1
Ignore vendor folder with mod=readonly 2022-09-30 11:26:05 -06:00
Matthew Holt
e4c5f53dd2 Don't include version in replacement source
Follow-up to #69

I had a situation where caddy/v2 v2.4.6 was in my go.mod and a replace
on it to use local caddy repo.

When I ran `xcaddy run` to test a caddy module, it failed to run because
the replace included the version v2.4.6, even though somehow the buildenv
go.mod had v2.6.1 (the latest), and the replace directive specified
@v2.4.6 only, so the replacement didn't happen.

I don't think versions in the replacement source/origin are
really that useful for xcaddy.

If experience proves this wrong, we can figure out a better solution.
2022-09-28 10:25:41 -06:00
ydylla
25c412f1ec
Always prepend caddy command with dot (#117)
Fix xcaddy run on windows with go 1.19

See https://github.com/golang/go/issues/43724
2022-09-12 13:41:27 -06:00
Francis Lavoie
0bd3c1dfd5
README: Add example for building from a github fork (#115) 2022-09-01 17:43:36 -06:00
Mohammed Al Sahaf
e6eb334d4e
core: add XCADDY_GO_MOD_FLAGS env var to allow passing custom go mod flags (#113) 2022-08-16 21:27:48 +00:00
Aapo Keskimölö
edc1f41778
Inject XCADDY_GO_BUILD_FLAGS through go operations (#102) (#110)
* Extend XCADDY_GO_BUILD_FLAGS usage (#102)

Commit 47f9ded5d8 is not sufficient alone to
ensure that all go modules are installed with write bit set because 'go mod'
or 'go get' might install modules as read-only, too.

If set, the environment variable is appended for the other go commands that
support build flags.

* Make running 'go' implicit for build environment

The method newCommand runs only go commands so let's make command 'go'
implicit and rename it to make it more verbose.
2022-08-16 19:19:15 +00:00
Matthew Holt
979de371dd
Remove GO111MODULE
Ignored as of Go 1.17
2022-08-05 10:06:15 -06:00
Matthew Holt
7577d60f61
Tolerate module file paths with @ in them
But version must also be specified to disambiguate.

Fix #109
2022-07-29 16:49:34 -06:00
Aapo Keskimölö
47f9ded5d8
Add XCADDY_GO_BUILD_FLAGS env var (#104)
Add environment variable

 XCADDY_GO_BUILD_FLAGS

to override default build arguments from environment (#102).

To support flags with variable arguments Unix-style quoting is supported.
2022-06-20 13:20:05 -06:00
Mohammed Al Sahaf
a83fac18bf
refactor: swap use html/template for text/template (#103) 2022-06-12 17:58:35 +00:00
Francis Lavoie
9cc6040a09
chore: Fix Debian install instructions
See https://github.com/caddyserver/dist/issues/83 for context
2022-05-17 11:07:12 -04:00
Peter Magnusson
7abc7f5752
Do not use only hardcoded "go" (#97)
* fix: do not use only hardcoded "go"

* fixed comments and added env to readme

* move GetGo to an internal package

Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2022-04-25 10:13:12 -06:00
Francis Lavoie
71ce25d1a2
Prevent main Caddy module from upgrading from adding a plugin (#93)
* Prevent main Caddy module from upgrading from adding a plugin

Fixes #54

* Better comment
2022-04-07 17:07:11 -06:00
Francis Lavoie
7d6084b6d7
Emit main.go contents to log; update CI (#95)
* Log out main.go contents

* Ignore `caddy` binary when using `./xcaddy` for testing

* Update CI, switch linter to match Caddy repo
2022-04-07 16:33:47 -06:00
Mohammed Al Sahaf
58e714eb0e
run go get -d at the end of prepping new env (#92) 2022-04-05 19:44:21 +03:00
Silas Rech
0b7d07c7a5
Add git ref documentation (#88)
Closes #87
2022-03-25 12:24:30 -06:00
Mohammed Al Sahaf
996c8d9d08
fix: skip cleanup if build is skipped (#83) 2022-02-19 15:26:52 -07:00
MisakaCloud
c7959560b5
Support dlv when debug enabled (#81)
* allow dlv when enable debug

* add comment

* merge two condition

* Update builder.go

Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
2022-02-16 13:26:25 -07:00
Francis Lavoie
c8b2d00673
docs: Update README to mention xcaddy version, cleanup (#71) 2021-09-03 19:36:13 -06:00
Mohammed Al Sahaf
8a353a02b6
ci: revert goreleaser workaround precereating xcaddy-build (#70) 2021-09-03 14:13:19 +00:00
Hyeon Kim (김지현)
3d8622df25
Handle replacements robustly (#69)
* Parse JSON output of 'go list'

It's more robust in this way

* Handle all possible replacements properly for runDev()

1.  Handle all possible replacements properly for runDev()

    Replacement targets are not always paths.

    Reference:
      https://pkg.go.dev/cmd/go/internal/list#pkg-variables

2.  Parse replacement info from 'go list -m -json all'

    It's more robust in this way

* Test the 'go list -m -json all' parsing logic

* Call 'go list' command only once

`go list -m -json all` contains all informations we need so we don't
need extra `go list -m -json` call.

* main_windows_test.go: Make tests for Windows

* Support Go 1.16

* Use struct instead of map[string]interface{}

* extract and unexport the `module` struct

Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2021-09-01 18:30:45 +00:00
Francis Lavoie
220c0dbbdc cmd: Set up main.go, similar to caddy, for retaining version info
cmd: Sync up release jobs with caddy repo

ci: fix the build dir for xcaddy goreleaser flow
2021-08-30 21:15:04 +03:00
Francis Lavoie
82e7b6aff2 cmd: Add xcaddy version command
cmd: Fix tests
2021-08-30 21:15:04 +03:00
Francis Lavoie
b8a0d46648
ci: Use Go 1.17 (#66) 2021-08-27 14:15:04 +00:00
Ggicci
8c5d3f1cf6
Keep DWARF info by setting XCADDY_DEBUG=1 (#62)
* feat: add --debug option to build a debug output

* chore: renaming

* chore: update README

* fix: typo

* feat: introduce env XCADDY_DEBUG

* fix: remove unnecessary change
2021-07-03 17:57:17 -06:00
Matthew Holt
652d45d08e
ci: Use Go 1.16 2021-05-05 16:13:13 -06:00
Mohammed Al Sahaf
83bc5a7c58
accept replacements with branches of github forks (#51)
* accept replacements with branches of github forks

Closes #50

* remove `!filepath.IsAbs(repl)` when checking path of replacement

If the replacement path starts with a `.`, then the path is definitely not absolute.
2021-02-26 22:49:50 +00:00
Matthew Holt
83655481bf
docs: Update readme install instructions 2021-02-22 13:16:27 -07:00
Francis Lavoie
891c8f95f9
docs: Add cloudsmith repo to install instructions (#49)
* docs: Add cloudsmith repo to install instructions

* Update README.md

* docs: Remove -a from tee
2021-02-22 13:14:46 -07:00
Francis Lavoie
c2133748db
Resolve relative replacements for xcaddy build as well (#48) 2021-02-15 11:28:34 -07:00
Kévin Dunglas
5734acdd58
Add XCADDY_SKIP_BUILD option (#41)
* feat: add XCADDY_NO_BUILD to not run go build

* Rename XCADDY_NO_BUILD to XCADDY_SKIP_BUILD

* fix rebase
2021-02-05 16:34:51 -07:00
Mohammed Al Sahaf
e7b19b13a2
Run go mod tidy in the build environment (#47)
* Run `go mod tidy` in the build environment

As of go 1.16, the `go {build,test}` commands don't modify the go.mod and go.sum files (see: https://golang.org/issue/40728). We, therefore, have to run `go mod tidy` to ensure the go.mod and go.sum files are consistent with the module requirements.

Closes #46

* check the error of `go mod tidy`
2021-02-05 10:49:17 -07:00
Matthew Holt
dabafeef18
Support setcap in dev mode (XCADDY_SETCAP)
When I first wrote xcaddy I was on macOS which does not
require permission to bind to low ports. Now I'm on Linux.

The XCADDY_SETCAP env var will cause xcaddy to run setcap
on the generated temporary binary before executing it
so that it can bind to low ports. This requires sudo.
2021-01-20 12:17:46 -07:00
Matthew Holt
623c361726
Resolve relative replacements
This allows us to use user-defined replacements that have a
relative path, since our temporary modules exist in different dirs.
2021-01-19 14:49:54 -07:00
Francis Lavoie
a9fc1ead03
ci: Fix echo message on Cloudsmith push (#43)
We're actually pushing to the `xcaddy` cloudsmith repo, not `testing` (copy-pasted from `caddy` repo, so it had the wrong string). Purely a visual bug.
2020-12-30 11:56:40 -07:00
Francis Lavoie
a341e5403d
ci: Pull updates from Caddy, build .deb as well (#42)
* ci: Pull updates from Caddy, build .deb as well

* ci: Pull ci.yml updates from Caddy, including testing on Go 1.15

* ci: Add publishing to Cloudsmith

* ci: Update release.yml to match changes in Caddy

* ci: Switch to keeping armv7 as the armhf .deb
2020-12-30 11:06:56 -07:00
Matthew Holt
f74ee60bd8
Update readme, specify local binary when executing 2020-12-28 08:49:32 -07:00
Jayson Reis
4f3e0ef756
Fix main.go generation when executing on a windows machine (#32)
* Fix main.go generation when executing on a windows machine

When normalizing the `importPath` it will try to write on `main.go` files with imports
like `github.com/caddyserver/xcaddy/c:\xcaddy`

* Apply CR suggestions

* Add test cases for sub-paths on normalizeImportPath

* Run windows tests only when GOOS matches
2020-09-25 17:39:48 -06:00
Jayson Reis
13c49c3566
Fix runDev when running on windows (#33)
Extract default output file to a function and reuse it in both runBuild and runDev
2020-08-26 12:36:51 -06:00
Francis Lavoie
53742c9c2d
Update .gitignore (#31) 2020-08-19 07:09:48 -06:00
jpughcs
b7fd102f41
Support go.mod replace version pinning (#27)
* support go.mod replace version pinning

* use string replace instead of regex

* Minor cleanups

Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
2020-08-10 12:27:38 -06:00
Mohammed Al Sahaf
1fec98156c
ci: immediately publish releases on tags (#26) 2020-07-31 22:18:53 +00:00
Matthew Holt
e11b1988bd
readme: Add env var docs 2020-07-16 16:07:50 -06:00
Matthew Holt
1d18c5862c
Rename ModulePath -> PackagePath
Technically they are packages to be imported, not necessarily paths to
the containing Go module.
2020-07-15 17:45:32 -06:00
Matthew Holt
3742b72df8
Optionally skip cleanup; fix cgo when race detector enabled 2020-07-15 17:44:06 -06:00
Matthew Holt
8266ddc40e
Handle package import paths that are in subfolders of Go module path 2020-06-16 15:08:00 -06:00
Matthew Holt
823a072ae1
Only run compiled binary if same platform (fixes #20) 2020-05-26 16:42:56 -06:00