Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.wit text eol=lf
24 changes: 13 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
build:
name: Build binaries
permissions:
contents: write
contents: read
runs-on: ubuntu-latest

strategy:
Expand All @@ -25,10 +25,10 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version-file: go.mod

Expand All @@ -49,31 +49,33 @@ jobs:
rm wit-bindgen-go

- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: wit-bindgen-go_${{ matrix.goos }}_${{ matrix.goarch }}
path: build/wit-bindgen-go-${{ matrix.goos }}-${{ matrix.goarch }}.tgz
retention-days: 1

release:
name: Create GitHub release
permissions:
contents: write
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v7

- name: Download Artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v8
with:
path: build/
merge-multiple: true # all artifacts are downloaded to this directory

- name: Extract release notes
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
cd $GITHUB_WORKSPACE
./scripts/extract-changelog.sh $TAG_NAME > RELEASE_NOTES.md
cd "$GITHUB_WORKSPACE"
./scripts/extract-changelog.sh "$TAG_NAME" > RELEASE_NOTES.md
cat RELEASE_NOTES.md

- name: Create release
Expand All @@ -83,12 +85,12 @@ jobs:
ls -R build/
TAG_NAME=${GITHUB_REF#refs/tags/}
if [[ "$TAG_NAME" =~ .+-pre.* ]]; then
PRERELEASE_ARGS="--prerelease --latest=false"
PRERELEASE_ARGS=(--prerelease --latest=false)
else
PRERELEASE_ARGS=""
PRERELEASE_ARGS=()
fi
gh release create "${{ github.ref_name }}" \
--notes-file RELEASE_NOTES.md \
--title "${{ github.ref_name }}" \
$PRERELEASE_ARGS \
"${PRERELEASE_ARGS[@]}" \
build/*
51 changes: 23 additions & 28 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ on:
- 'docs/**'
- 'LICENSE'

permissions:
contents: read

env:
GOTOOLCHAIN: local
go-modules: ./... ./cm/...
wasm-tools-version: "1.230.0"
wasmtime-version: "26.0.0"
Expand All @@ -25,12 +29,12 @@ jobs:
timeout-minutes: 2
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
submodules: recursive

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version-file: go.mod

Expand All @@ -40,19 +44,20 @@ jobs:
# Test with Go
test-go:
name: Test with Go
runs-on: ubuntu-latest
timeout-minutes: 15
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
matrix:
go-version: ["1.23", "1.24"]
os: [ubuntu-latest, windows-latest]
go-version: ["1.26", "1.27"]
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
submodules: recursive

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go-version }}

Expand All @@ -77,24 +82,21 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
go-version: ["1.23", "1.24"]
tinygo-version: ["0.35.0", "0.36.0", "0.37.0"]
exclude:
- go-version: "1.24"
tinygo-version: "0.35.0"
go-version: ["1.26", "1.27"]
tinygo-version: ["0.43.0"]
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
submodules: recursive

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go-version }}

- name: Set up TinyGo
uses: acifani/setup-tinygo@v2
uses: acifani/setup-tinygo@v3
with:
tinygo-version: ${{ matrix.tinygo-version }}

Expand All @@ -111,24 +113,21 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
go-version: ["1.23", "1.24"]
tinygo-version: ["0.35.0", "0.36.0", "0.37.0"]
exclude:
- go-version: "1.24"
tinygo-version: "0.35.0"
go-version: ["1.26", "1.27"]
tinygo-version: ["0.43.0"]
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v7
with:
submodules: recursive

- name: Set up Go
uses: actions/setup-go@v5
uses: actions/setup-go@v7
with:
go-version: ${{ matrix.go-version }}

- name: Set up TinyGo
uses: acifani/setup-tinygo@v2
uses: acifani/setup-tinygo@v3
with:
tinygo-version: ${{ matrix.tinygo-version }}

Expand All @@ -144,11 +143,7 @@ jobs:
version: ${{ env.wasmtime-version }}

- name: Add Go wasm exec to $PATH
run: echo "$(go env GOROOT)/misc/wasm" >> $GITHUB_PATH

# This moved in Go 1.24: https://github.com/golang/go/issues/68024
- name: Add Go 1.24 wasm exec to $PATH
run: echo "$(go env GOROOT)/lib/wasm" >> $GITHUB_PATH
run: echo "$(go env GOROOT)/lib/wasm" >> "$GITHUB_PATH"

- name: Regenerate Go
run: make tests/generated
Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module go.bytecodealliance.org

go 1.23.0
go 1.26.0

require (
github.com/coreos/go-semver v0.3.1
github.com/regclient/regclient v0.8.3
github.com/regclient/regclient v0.11.5
github.com/sergi/go-diff v1.3.1
github.com/tetratelabs/wazero v1.9.0
github.com/urfave/cli/v3 v3.3.8
Expand All @@ -15,10 +15,10 @@ require (

require (
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/klauspost/compress v1.18.7 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/ulikunitz/xz v0.5.12 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/sys v0.45.0 // indirect
)
33 changes: 18 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,54 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4=
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE=
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/klauspost/compress v1.18.7 h1:aUyZsS4kH3QTKurYhAOwAHxllVPnOthb3vPfnF1Ehjw=
github.com/klauspost/compress v1.18.7/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/olareg/olareg v0.1.2 h1:75G8X6E9FUlzL/CSjgFcYfMgNzlc7CxULpUUNsZBIvI=
github.com/olareg/olareg v0.1.2/go.mod h1:TWs+N6pO1S4bdB6eerzUm/ITRQ6kw91mVf9ZYeGtw+Y=
github.com/olareg/olareg v0.2.1 h1:RPHGIaqlVWPbKAsOYUj7e2WfEEW5M7F8I6hKMrwd4jU=
github.com/olareg/olareg v0.2.1/go.mod h1:dhr8QetC7U7jJ2m93oxDhEEOKCRbPgOK1oGyKfB4QNo=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/regclient/regclient v0.8.3 h1:AFAPu/vmOYGyY22AIgzdBUKbzH+83lEpRioRYJ/reCs=
github.com/regclient/regclient v0.8.3/go.mod h1:gjQh5uBVZoo/CngchghtQh9Hx81HOMKRRDd5WPcPkbk=
github.com/regclient/regclient v0.11.5 h1:OHRsXO0F3qHGfa4HEUv+EkMH9NXNcCTBKjNzyC/UhIA=
github.com/regclient/regclient v0.11.5/go.mod h1:DZUOfIT14WFTK2Pj4vjd93avy9O4Fdpjrf9ir23TbRE=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/sirupsen/logrus v1.9.4 h1:TsZE7l11zFCLZnZ+teH4Umoq5BhEIfIzfRDZ1Uzql2w=
github.com/sirupsen/logrus v1.9.4/go.mod h1:ftWc9WdOfJ0a92nsE2jF5u5ZwH8Bv2zdeOC42RjbV2g=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/sudo-bmitch/oci-digest v0.1.2 h1:are0qzWTsFZGZ3Uvdi9OSztJszSWaab6iqquMEEB7rw=
github.com/sudo-bmitch/oci-digest v0.1.2/go.mod h1:SH6l5OIe0islKBZBedjiPOeET/0QwGL+/oYfQt51uQo=
github.com/tetratelabs/wazero v1.9.0 h1:IcZ56OuxrtaEz8UYNRHBrUa9bYeX9oVY93KspZZBf/I=
github.com/tetratelabs/wazero v1.9.0/go.mod h1:TSbcXCfFP0L2FGkRPxHphadXPjo1T6W+CseNNY7EkjM=
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY=
github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli/v3 v3.3.8 h1:BzolUExliMdet9NlJ/u4m5vHSotJ3PzEqSAZ1oPMa/E=
github.com/urfave/cli/v3 v3.3.8/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo=
go.bytecodealliance.org/cm v0.3.0 h1:VhV+4vjZPUGCozCg9+up+FNL3YU6XR+XKghk7kQ0vFc=
go.bytecodealliance.org/cm v0.3.0/go.mod h1:JD5vtVNZv7sBoQQkvBvAAVKJPhR/bqBH7yYXTItMfZI=
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU=
golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.23.0
go 1.26.0

use (
.
Expand Down
13 changes: 4 additions & 9 deletions internal/go/gen/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,12 @@ func PackagePath(dir string) (string, error) {
file = filepath.Join(dir, "go.mod")
info, err := os.Stat(file)
if err != nil {
if dir == "/" {
parent := filepath.Dir(dir)
if parent == dir {
return "", errors.New("unable to locate a go.mod file")
}
// Pop up to parent dir
var rest string
dir, rest = filepath.Split(dir)
if dir == "" {
return "", errors.New("unable to locate a go.mod file")
}
dir = filepath.Clean(dir)
subdirs = path.Join(rest, subdirs)
subdirs = path.Join(filepath.Base(dir), subdirs)
dir = parent
continue
}
if info.IsDir() {
Expand Down
32 changes: 32 additions & 0 deletions internal/go/gen/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gen

import (
"os"
"path/filepath"
"testing"

"go.bytecodealliance.org/internal/relpath"
Expand All @@ -28,3 +29,34 @@ func TestPackagePath(t *testing.T) {
t.Errorf("PackagePath(%q): expected error, got nil", tmp)
}
}

func TestPackagePathNestedModule(t *testing.T) {
root, err := os.MkdirTemp("", t.Name()+"-")
if err != nil {
t.Fatal(err)
}
module := filepath.Join(root, "go.mod")
internal := filepath.Join(root, "internal")
nested := filepath.Join(internal, "bindings")
// TinyGo lacks recursive removal on Windows and WASI.
t.Cleanup(func() {
for _, path := range []string{nested, internal, module, root} {
if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
t.Errorf("remove test fixture %s: %v", path, err)
}
}
})
if err := os.WriteFile(module, []byte("module example.com/plugin\n\ngo 1.26.0\n"), 0o600); err != nil {
t.Fatal(err)
}
if err := os.MkdirAll(nested, 0o700); err != nil {
t.Fatal(err)
}
got, err := PackagePath(nested)
if err != nil {
t.Fatal(err)
}
if want := "example.com/plugin/internal/bindings"; got != want {
t.Errorf("PackagePath(%q) = %q, want %q", nested, got, want)
}
}
Loading
Loading