Skip to content

Commit

Permalink
chore: automate the creation of a release (#776)
Browse files Browse the repository at this point in the history
* chore: automate the creation of tags for all modules

* chore: release the entire library with the same script

* chore: support pushing the new module versions to pkg.go.dev

* chore: consistency in variable names

* chore: extract tagging to a function

* chore: extract curl to a function

* chore: extract git push to a function

* chore: extract to main function

* chore: support running the script in DRY_RUN mode

* fix: loop through all modules

* fix: remove extra slash in URL

* docs: document the script

* chore: extract version from version file

* docs: link to pkg.go.dev for info

* docs: document the release script

* fix: do not POST

* feat: add localstack module (#800)

* chore: add localstack basic example

Run "go run . --name localstack --image "localstack/localstack:0.11.2" --title LocalStack"

* chore: add wait for log

* chore: add Docker socket binding

* chore: support defining legacy mode

* chore: support passing services and configuring them

* chore: simplify the creation of a localstack container request

It will allow users not to pass the legacy mode everywhere. Instead,
it's defined in the initial request, and consumed downstream

* chore: support configuring the AWS region

* chore: expose localstack container

* chore: support for retrieving the endpoint of a given service

* chore: store enabled services in the localstack container

* chore: store the region in the localstack container

* chore: apply default region when needed

* chore: support passing version and legacyMode as functional options

* chore: support for overriding the container request with a functional option

* chore: remove useless method for retrieving the internal endpoint of a service

* chore: simplify unit tests

* chore: create aws session using v1

* chore: add S3 tests

* chore: rename start localstack function

* chore: define default functions as vars

* chore: add tests for legacy mode

* chore: move the Session code to the tests

We want to et the user define how to get the Session

* docs: use S3 in the docs

* fix: read the expected daemon host from the provider

* chore: move v1 tests to its own test package

* feat: add example test for S3 using v2

* chore: store localstack credentials in a struct

* feat: create a functional opt for passing the AWS credentials

* chore: define defaults for the AWS credentials

* chore: include a test for overriding the image

* chore: remove withCredentials

Set them up using the override, as it's as simple as adding the right env vars

* chore: remove withRegion

Set it up using the override, as it's as simple as adding the right env var

* chore: remove withVersion

Set them up using the override, as it's as simple as setting the req.Image

* chore: rename configure method

* chore: reorder container configuration

1. merge the override request
2. set up the functional opts
3. configure Docker host

* chore: move to types

* chor: export structs

* docs: document exported functions

* docs: document how to create localstack container

* docs: reorder

* docs: document containerRequest override

* docs: document the container functional opts

* chore: be more explicit in comment

Co-authored-by: Eddú Meléndez Gonzales <[email protected]>

* chore: convert into real module

* chore: remove support for legacy mode

* chore: move tests

* fix: update module paths

* fix: update tests after moving an example to modules

* chore: bump default version to 1.3.1

* chore: remove Port from the Service struct

If the user wants to use the legacy mode, then they should build the
environment accordingly (e.g. SERVICES env var)

* fix: wrong relative path to the docs

* chore: remove any code to Services

We'll delegate it to the user, using the localstack env vars

* chore: adjust unit tests

* docs: include tests

* chore: use waitFor HTTP health

* chore: bump to latest version

* chore: go mod examples

* chore: rename GH action workflow file

---------

Co-authored-by: Eddú Meléndez Gonzales <[email protected]>

* chore(deps): bump go.mongodb.org/mongo-driver in /examples/mongodb (#831)

Bumps [go.mongodb.org/mongo-driver](https://github.com/mongodb/mongo-go-driver) from 1.11.1 to 1.11.2.
- [Release notes](https://github.com/mongodb/mongo-go-driver/releases)
- [Commits](mongodb/mongo-go-driver@v1.11.1...v1.11.2)

---
updated-dependencies:
- dependency-name: go.mongodb.org/mongo-driver
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump google.golang.org/api from 0.109.0 to 0.110.0 in /examples (#836)

* chore(deps): bump google.golang.org/api in /examples/bigtable

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/api in /examples/spanner

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/api in /examples/pubsub

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/api in /examples/firestore

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/api in /examples/datastore

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: support generating Go modules or example modules (#826)

* chore: create a separate module for the generator

* chore: get the root directory in the new layout

* feat: support for creating modules or examples

* fix: update dependabot and mkdocs

* chore: extract example parent dir calculation to a function

* chore: define entrypoint and container name methods

* chore: rename setupTech to startContainer

* chore: rename setup function in example modules

* chor: include modulegen in dependabot

* chore: add build script for modulegen

* chore: include modulegen tests in CI

* fix: update tests

* docs: add missing dependabot entry

* chore: update GH workflow example type

* fix: do not depend on hardcoded lengths

* chore: generate modules in its own directory in docs

* chore: add build script for modules

* docs: reuse

* chore(deps): bump github.com/imdario/mergo in /modules/localstack (#828)

Bumps [github.com/imdario/mergo](https://github.com/imdario/mergo) from 0.3.12 to 0.3.13.
- [Release notes](https://github.com/imdario/mergo/releases)
- [Commits](darccio/mergo@0.3.12...v0.3.13)

---
updated-dependencies:
- dependency-name: github.com/imdario/mergo
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/aws/aws-sdk-go in /modules/localstack (#835)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.44.192 to 1.44.200.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Commits](aws/aws-sdk-go@v1.44.192...v1.44.200)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* fix: always absolute paths when tarring files to a Docker container (#814)

* chore: extract to variable to avoid double calculation

* chore: add tests including absolute paths

* chore: merge tests using a test table

* fix: keep parent directory as the root of the TAR file

* docs: document the change

* chore: make the path OS-agnostic

* chore: simplify

* fix: use filepath to be OS-independent

* chore(deps): bump github.com/jackc/pgx/v4 in /examples/cockroachdb (#819)

Bumps [github.com/jackc/pgx/v4](https://github.com/jackc/pgx) from 4.17.2 to 4.18.0.
- [Release notes](https://github.com/jackc/pgx/releases)
- [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md)
- [Commits](jackc/pgx@v4.17.2...v4.18.0)

---
updated-dependencies:
- dependency-name: github.com/jackc/pgx/v4
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump golang.org/x/sys from 0.4.0 to 0.5.0 (#816)

Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.4.0 to 0.5.0.
- [Release notes](https://github.com/golang/sys/releases)
- [Commits](golang/sys@v0.4.0...v0.5.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump golang.org/x/text from 0.6.0 to 0.7.0 (#818)

Bumps [golang.org/x/text](https://github.com/golang/text) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/text/releases)
- [Commits](golang/text@v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/text
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/containerd/containerd from 1.6.16 to 1.6.17 (#817)

Bumps [github.com/containerd/containerd](https://github.com/containerd/containerd) from 1.6.16 to 1.6.17.
- [Release notes](https://github.com/containerd/containerd/releases)
- [Changelog](https://github.com/containerd/containerd/blob/main/RELEASES.md)
- [Commits](containerd/containerd@v1.6.16...v1.6.17)

---
updated-dependencies:
- dependency-name: github.com/containerd/containerd
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump google.golang.org/grpc from 1.52.3 to 1.53.0 in /examples (#827)

* chore(deps): bump google.golang.org/grpc in /examples/pubsub

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.3 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.52.3...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/grpc in /examples/spanner

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.3 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.52.3...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/grpc in /examples/bigtable

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.3 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.52.3...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/grpc in /examples/datastore

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.3 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.52.3...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/grpc in /examples/firestore

Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.52.3 to 1.53.0.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.52.3...v1.53.0)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: add localstack module (#800)

* chore: add localstack basic example

Run "go run . --name localstack --image "localstack/localstack:0.11.2" --title LocalStack"

* chore: add wait for log

* chore: add Docker socket binding

* chore: support defining legacy mode

* chore: support passing services and configuring them

* chore: simplify the creation of a localstack container request

It will allow users not to pass the legacy mode everywhere. Instead,
it's defined in the initial request, and consumed downstream

* chore: support configuring the AWS region

* chore: expose localstack container

* chore: support for retrieving the endpoint of a given service

* chore: store enabled services in the localstack container

* chore: store the region in the localstack container

* chore: apply default region when needed

* chore: support passing version and legacyMode as functional options

* chore: support for overriding the container request with a functional option

* chore: remove useless method for retrieving the internal endpoint of a service

* chore: simplify unit tests

* chore: create aws session using v1

* chore: add S3 tests

* chore: rename start localstack function

* chore: define default functions as vars

* chore: add tests for legacy mode

* chore: move the Session code to the tests

We want to et the user define how to get the Session

* docs: use S3 in the docs

* fix: read the expected daemon host from the provider

* chore: move v1 tests to its own test package

* feat: add example test for S3 using v2

* chore: store localstack credentials in a struct

* feat: create a functional opt for passing the AWS credentials

* chore: define defaults for the AWS credentials

* chore: include a test for overriding the image

* chore: remove withCredentials

Set them up using the override, as it's as simple as adding the right env vars

* chore: remove withRegion

Set it up using the override, as it's as simple as adding the right env var

* chore: remove withVersion

Set them up using the override, as it's as simple as setting the req.Image

* chore: rename configure method

* chore: reorder container configuration

1. merge the override request
2. set up the functional opts
3. configure Docker host

* chore: move to types

* chor: export structs

* docs: document exported functions

* docs: document how to create localstack container

* docs: reorder

* docs: document containerRequest override

* docs: document the container functional opts

* chore: be more explicit in comment

Co-authored-by: Eddú Meléndez Gonzales <[email protected]>

* chore: convert into real module

* chore: remove support for legacy mode

* chore: move tests

* fix: update module paths

* fix: update tests after moving an example to modules

* chore: bump default version to 1.3.1

* chore: remove Port from the Service struct

If the user wants to use the legacy mode, then they should build the
environment accordingly (e.g. SERVICES env var)

* fix: wrong relative path to the docs

* chore: remove any code to Services

We'll delegate it to the user, using the localstack env vars

* chore: adjust unit tests

* docs: include tests

* chore: use waitFor HTTP health

* chore: bump to latest version

* chore: go mod examples

* chore: rename GH action workflow file

---------

Co-authored-by: Eddú Meléndez Gonzales <[email protected]>

* chore(deps): bump go.mongodb.org/mongo-driver in /examples/mongodb (#831)

Bumps [go.mongodb.org/mongo-driver](https://github.com/mongodb/mongo-go-driver) from 1.11.1 to 1.11.2.
- [Release notes](https://github.com/mongodb/mongo-go-driver/releases)
- [Commits](mongodb/mongo-go-driver@v1.11.1...v1.11.2)

---
updated-dependencies:
- dependency-name: go.mongodb.org/mongo-driver
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump google.golang.org/api from 0.109.0 to 0.110.0 in /examples (#836)

* chore(deps): bump google.golang.org/api in /examples/bigtable

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/api in /examples/spanner

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/api in /examples/pubsub

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/api in /examples/firestore

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore(deps): bump google.golang.org/api in /examples/datastore

Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.109.0 to 0.110.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.109.0...v0.110.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: support generating Go modules or example modules (#826)

* chore: create a separate module for the generator

* chore: get the root directory in the new layout

* feat: support for creating modules or examples

* fix: update dependabot and mkdocs

* chore: extract example parent dir calculation to a function

* chore: define entrypoint and container name methods

* chore: rename setupTech to startContainer

* chore: rename setup function in example modules

* chor: include modulegen in dependabot

* chore: add build script for modulegen

* chore: include modulegen tests in CI

* fix: update tests

* docs: add missing dependabot entry

* chore: update GH workflow example type

* fix: do not depend on hardcoded lengths

* chore: generate modules in its own directory in docs

* chore: add build script for modules

* docs: reuse

* fix: always pass the absolute path to the tar code

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>

* chore(deps): bump github.com/docker/compose/v2 from 2.15.1 to 2.16.0 in /modules/compose (#824)

* chore(deps): bump github.com/docker/compose/v2 in /modules/compose

Bumps [github.com/docker/compose/v2](https://github.com/docker/compose) from 2.15.1 to 2.16.0.
- [Release notes](https://github.com/docker/compose/releases)
- [Commits](docker/compose@v2.15.1...v2.16.0)

---
updated-dependencies:
- dependency-name: github.com/docker/compose/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* chore: remove replace directives

* chore: bump Docker dependencies to v23.0.0+incompatible

* chore: use proper docker APIs

* chore: use proper docker APIs

* fix: use non-deprecated API

* chore: remove replace directives for Docker in the docs

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Manuel de la Peña <[email protected]>

* chore: run in dry-run mode by default

* chore: bump the version file to the next minor

* chore: support for setting the bump type (major, minor, patch)

* chore: update mkdocs.yml file

* chore: reduce post-script instructions

* chore: restore git state

* chore: extract git to a function

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Eddú Meléndez Gonzales <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Feb 16, 2023
1 parent 8d2cb1a commit a92f198
Show file tree
Hide file tree
Showing 2 changed files with 244 additions and 0 deletions.
81 changes: 81 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Releasing Testcontainers for Go

In order to create a release, we have added a shell script that performs all the tasks for you, allowing a dry-run mode for checking it before creating the release. We are going to explain how to use it in this document.

First, it's really important that you first check that the [version.go](./internal/version.go) file is up-to-date, containing the right version you want to create. That file will be used by the automation to perform the release.
Once the version file is correct in the repository:

- Run the [release.sh](./scripts/release.sh) shell script to run it in dry-run mode.
- You can run the script without dry-run setting `DRY_RUN=false` in the environment:

DRY_RUN="false" ./scripts/release.sh

- The script will create a git tag with the current value of the [version.go](./internal/version.go) file, starting with `v`: e.g. `v0.18.0`, for the following Go modules:
- the root module, representing the Testcontainers for Go library.
- all the Go modules living in both the `examples` and `modules` directory. The git tag value for these Go modules will be created using this name convention:

"${directory}/${module_name}/${version}", e.g. "examples/mysql/v0.18.0", "modules/compose/v0.18.0"

- The script will update the [mkdocs.yml](./mkdocks.yml) file, updating the `latest_version` field to the current version.
- The script will update the [version.go](./internal/version.go) file, setting the next development version to the next **minor** version by default. For example, if the current version is `v0.18.0`, the script will update the [version.go](./internal/version.go) file with the next development version `v0.19.0`.
- You can define the bump type, using the `BUMP_TYPE` environment variable. The default value is `minor`, but you can also use `major` or `patch` (the script will fail if the value is not one of these three):

BUMP_TYPE="major" ./scripts/release.sh

- The script will create a commit in the **main** branch.
- The script will push the git the main branch including the tags to the upstream repository, https://github.com/testcontainers/testcontainers-go

An example execution, with dry-run mode enabled:

```
$ ./scripts/release.sh
git tag v0.18.0
git tag examples/bigtable/v0.18.0
git tag examples/cockroachdb/v0.18.0
git tag examples/consul/v0.18.0
git tag examples/datastore/v0.18.0
git tag examples/firestore/v0.18.0
git tag examples/mongodb/v0.18.0
git tag examples/mysql/v0.18.0
git tag examples/nginx/v0.18.0
git tag examples/postgres/v0.18.0
git tag examples/pubsub/v0.18.0
git tag examples/pulsar/v0.18.0
git tag examples/redis/v0.18.0
git tag examples/spanner/v0.18.0
git tag examples/toxiproxy/v0.18.0
git tag modules/compose/v0.18.0
git tag modules/localstack/v0.18.0
git stash
git checkout main
Producing a minor bump of the version, from v0.18.0 to 0.19.0
sed "s/const Version = ".*"/const Version = "0.19.0"/g" /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/internal/version.go > /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/internal/version.go.tmp
mv /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/internal/version.go.tmp /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/internal/version.go
sed "s/latest_version: .*/latest_version: v0.18.0/g" /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/mkdocs.yml > /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/mkdocs.yml.tmp
mv /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/mkdocs.yml.tmp /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/mkdocs.yml
git add /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/internal/version.go
git add /Users/mdelapenya/sourcecode/src/github.com/testcontainers/testcontainers-go/mkdocs.yml
git commit -m chore: prepare for next minor development cycle (0.19.0)
git push origin main --tags
git unstash
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/bigtable/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/cockroachdb/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/consul/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/datastore/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/firestore/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/mongodb/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/mysql/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/nginx/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/postgres/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/pubsub/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/pulsar/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/redis/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/spanner/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/examples/toxiproxy/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/modules/compose/@v/v0.18.0
curl https://proxy.golang.org/github.com/testcontainers/testcontainers-go/modules/localstack/@v/v0.18.0
```

Right after that, you have to:
- Verify that the commits are in the upstream repository, otherwise, update it with the current state of the main branch.
163 changes: 163 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
#!/usr/bin/env bash

# This script is used to release a new version of the Testcontainers for Go library.
# It creates a tag for the root module and for each module in the modules directory,
# and then triggers the Go proxy to fetch the module. BY default, it will be run in
# dry-run mode, which will print the commands that would be executed, without actually
# executing them.
#
# Usage: ./scripts/release.sh
#
# It's possible to run the script without dry-run mode actually executing the commands.
#
# Usage: DRY_RUN="false" ./scripts/release.sh

readonly DOCKER_IMAGE_SEMVER="docker.io/mdelapenya/semver-tool:3.4.0"
readonly DRY_RUN="${DRY_RUN:-true}"
readonly CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
readonly ROOT_DIR="$(dirname "$CURRENT_DIR")"
readonly MKDOCS_FILE="${ROOT_DIR}/mkdocs.yml"
readonly VERSION_FILE="${ROOT_DIR}/internal/version.go"
readonly BUMP_TYPE="${BUMP_TYPE:-minor}"

readonly REPOSITORY="github.com/testcontainers/testcontainers-go"

function main() {
readonly version="v$(extractCurrentVersion)"

tagModule "${version}"

readonly DIRECTORIES=(examples modules)

for directory in "${DIRECTORIES[@]}"
do
cd "${ROOT_DIR}/${directory}"

ls -d */ | grep -v "_template" | while read -r module; do
module="${module%?}" # remove trailing slash
module_tag="${directory}/${module}/${version}" # e.g. modules/mongodb/v0.0.1
tagModule "${module_tag}"
done
done

gitState
bumpVersion "${version}"
gitPushTags
gitUnstash

curlGolangProxy "${REPOSITORY}" "${version}" # e.g. github.com/testcontainers/testcontainers-go/@v/v0.0.1

for directory in "${DIRECTORIES[@]}"
do
cd "${ROOT_DIR}/${directory}"

ls -d */ | grep -v "_template" | while read -r module; do
module="${module%?}" # remove trailing slash
module_path="${REPOSITORY}/${directory}/${module}"
curlGolangProxy "${module_path}" "${version}" # e.g. github.com/testcontainers/testcontainers-go/modules/mongodb/@v/v0.0.1
done
done
}

# This function is used to bump the version in the version.go file and in the mkdocs.yml file.
function bumpVersion() {
local versionToBump="${1}"

local newVersion=$(docker run --rm "${DOCKER_IMAGE_SEMVER}" bump "${BUMP_TYPE}" "${versionToBump}")
echo "Producing a ${BUMP_TYPE} bump of the version, from ${versionToBump} to ${newVersion}"

if [[ "${DRY_RUN}" == "true" ]]; then
echo "sed \"s/const Version = \".*\"/const Version = \"${newVersion}\"/g\" ${VERSION_FILE} > ${VERSION_FILE}.tmp"
echo "mv ${VERSION_FILE}.tmp ${VERSION_FILE}"
else
sed "s/const Version = \".*\"/const Version = \"${newVersion}\"/g" ${VERSION_FILE} > ${VERSION_FILE}.tmp
mv ${VERSION_FILE}.tmp ${VERSION_FILE}
fi

if [[ "${DRY_RUN}" == "true" ]]; then
echo "sed \"s/latest_version: .*/latest_version: ${versionToBump}/g\" ${MKDOCS_FILE} > ${MKDOCS_FILE}.tmp"
echo "mv ${MKDOCS_FILE}.tmp ${MKDOCS_FILE}"
else
sed "s/latest_version: .*/latest_version: ${versionToBump}/g" ${MKDOCS_FILE} > ${MKDOCS_FILE}.tmp
mv ${MKDOCS_FILE}.tmp ${MKDOCS_FILE}
fi

gitCommitVersion "${newVersion}"
}

# This function is used to trigger the Go proxy to fetch the module.
# See https://pkg.go.dev/about#adding-a-package for more details.
function curlGolangProxy() {
local module_path="${1}"
local module_version="${2}"

if [[ "${DRY_RUN}" == "true" ]]; then
echo "curl https://proxy.golang.org/${module_path}/@v/${module_version}"
return
fi

# e.g.:
# github.com/testcontainers/testcontainers-go/v0.0.1
# github.com/testcontainers/testcontainers-go/modules/mongodb/v0.0.1
curl "https://proxy.golang.org/${module_path}/@v/${module_version}"
}

# This function reads the version.go file and extracts the current version.
function extractCurrentVersion() {
cat "${VERSION_FILE}" | grep 'const Version = ' | cut -d '"' -f 2
}

# This function is used to commit the version.go file.
function gitFn() {
args=("$@")
if [[ "${DRY_RUN}" == "true" ]]; then
echo "git ${args[@]}"
return
fi

git "${args[@]}"
}

# This function is used to commit the version.go file.
function gitCommitVersion() {
local newVersion="${1}"
gitFn add "${VERSION_FILE}"
gitFn add "${MKDOCS_FILE}"
gitFn commit -m "chore: prepare for next ${BUMP_TYPE} development cycle (${newVersion})"
}

# This function is used to push the tags to the remote repository.
function gitPushTags() {
gitFn push origin main --tags
}

# This function is setting the git state to the next development cycle:
# - Stashing the changes
# - Moving to the main branch
function gitState() {
gitFn stash
gitFn checkout main
}

function gitUnstash() {
gitFn unstash
}

# This function is used to create a tag for the module.
function tagModule() {
local module_tag="${1}"

gitFn tag -d "${module_tag}" | true # do not fail if tag does not exist
gitFn tag "${module_tag}"
}

function validate() {
# if bump_type is not major, minor or patch, the script will fail
if [[ "${BUMP_TYPE}" != "major" ]] && [[ "${BUMP_TYPE}" != "minor" ]] && [[ "${BUMP_TYPE}" != "patch" ]]; then
echo "BUMP_TYPE must be major, minor or patch. Current: ${BUMP_TYPE}"
exit 1
fi
}

validate
main "$@"

0 comments on commit a92f198

Please sign in to comment.