From 63d0bdcd8215b5fe39f214ba301ca66435c78cc4 Mon Sep 17 00:00:00 2001 From: Elvis Souza Date: Mon, 13 Mar 2023 20:33:33 -0300 Subject: [PATCH] Incremental Releasing (#359) * changes on actions job * [Gradle Release Plugin] - new version commit: '3.9.2'. * adjusting * adjusting artifacts upload * push only amd64 images * adjusting host artifacts retrieve * logs * fixing command * adjusting * adjusting release notes be to compliance with https://keepachangelog.com/en/1.0.0/ * notes * set app version * set app version * adjusting release header * fixing when tag already exists * adjusting release validator * adjusting release validator * adjusting release validator * bump * validating release * validating release * new try * new try * bump build * fixing output * bump * adjusting command * adjusting * bump * adjusting release for arm * speed up image release for testing * no need to checkout * no need to download all refs * no need to download all refs * fixing artifacts * removing unnecessary code * bump version --- .github/workflows/actions-deploy.yml | 88 ++++++++++++-- Dockerfile.builder.linux-aarch64 | 2 +- README.md | 3 +- RELEASE-NOTES.md | 175 ++++++++++++++------------- build.gradle | 12 ++ builder.bash | 42 +++++-- docker-compose-deploy.yml | 10 +- gradle.properties | 2 +- 8 files changed, 221 insertions(+), 113 deletions(-) diff --git a/.github/workflows/actions-deploy.yml b/.github/workflows/actions-deploy.yml index 7c1896030..ef1be6e0c 100644 --- a/.github/workflows/actions-deploy.yml +++ b/.github/workflows/actions-deploy.yml @@ -10,27 +10,95 @@ permissions: env: CURRENT_BRANCH: ${{ github.head_ref || github.ref_name }} + # github token to deploy the binary + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} jobs: - cd: + primary_release: runs-on: ubuntu-latest + outputs: + APP_VERSION: ${{ steps.set_app_version.outputs.APP_VERSION }} steps: - name: Explain run: | - echo "Bump version, build, generate github release, push docker images and the docs" + echo "Releases the Jar and Linux AMD64 version" - name: Checkout code uses: actions/checkout@v3 + + - name: Set app version + id: set_app_version + run: ./gradlew setVersionOnActions + + - name: Jar and Linux AMD64 Release + run: | + mkdir -p ./build/ \ + && docker-compose -f docker-compose-deploy.yml up --build --force-recreate --exit-code-from deploy deploy \ + && ls -lhS ./build/* + + - name: Upload Artifacts + uses: actions/upload-artifact@v3 + with: + name: native-image-source + path: ./build/artifacts/native-image-source/dns-proxy-server.jar + + - name: Latest version changelog extraction + uses: kemayo/actions-recent-changelog@v1 + with: + input: RELEASE-NOTES.md + output: VERSION-RELEASE-NOTES.md + - name: Check Release Notes + run: cat ./VERSION-RELEASE-NOTES.md + + - name: Github release + uses: softprops/action-gh-release@v1 with: - fetch-depth: '0' + tag_name: ${{ env.APP_VERSION }} + prerelease: true + body_path: VERSION-RELEASE-NOTES.md + files: | + ./build/compressed-artifacts/* + + linux_arm_release: + runs-on: ubuntu-latest + needs: primary_release + env: + APP_VERSION: ${{ needs.primary_release.outputs.APP_VERSION }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Check app version + run: echo "$APP_VERSION" + + - uses: actions/download-artifact@v3 + with: + name: native-image-source + path: ./build/artifacts/native-image-source/ - name: Configure Qemu run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes - - name: Deploy - run: docker-compose -f docker-compose-deploy.yml up --build --force-recreate --exit-code-from deploy deploy - env: - # github token to deploy the binary - REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + - name: Linux Arm Release + run: | + echo "app version=$APP_VERSION" &&\ + tree -h ./build/ &&\ + docker-compose -f docker-compose-deploy.yml run deploy bash -c ' + /bin/builder.bash deploy-arm &&\ + echo "> Copying files to the host" &&\ + cp -rv /app/build/compressed-artifacts /host/build/ &&\ + echo "Linux arm64 is done!" + ' &&\ + tree -h ./build/ + + # Release details will be provided by primary-release + - name: Github release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.APP_VERSION }} + append_body: true + body: '' + files: | + ./build/compressed-artifacts/* diff --git a/Dockerfile.builder.linux-aarch64 b/Dockerfile.builder.linux-aarch64 index bdf3eb66b..e57f523b6 100644 --- a/Dockerfile.builder.linux-aarch64 +++ b/Dockerfile.builder.linux-aarch64 @@ -5,7 +5,7 @@ COPY ./build/artifacts/native-image-source/ /app/build ENV JAVA_TOOL_OPTIONS='-Djdk.lang.Process.launchMechanism=fork' RUN uname -m && ls -lha &&\ native-image -Djdk.lang.Process.launchMechanism=fork -J-Djdk.lang.Process.launchMechanism=fork \ - -jar dns-proxy-server.jar + -jar dns-proxy-server.jar dns-proxy-server RUN ls -lhS &&\ mkdir -p ./artifacts/linux-aarch64 &&\ diff --git a/README.md b/README.md index 3e75f4c07..a5e2a4ef6 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ or via docker looking at [Dockerhub images][3]. Basic running it on Linux or Mac ```bash -$ curl -s -L https://github.com/mageddo/dns-proxy-server/releases/download/3.9.1/dns-proxy-server-linux-amd64-3.9.1.tgz | tar -vzx &&\ +$ curl -s -L https://github.com/mageddo/dns-proxy-server/releases/download/3.9.2/dns-proxy-server-linux-amd64-3.9.2.tgz | tar -vzx &&\ sudo ./dns-proxy-server ``` @@ -74,4 +74,3 @@ Or via QR code [5]: http://mageddo.github.io/dns-proxy-server/latest/en/1-getting-started/running-it/ [6]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PYFAZCXL442B6&source=url [7]: https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif - diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index f69cb1cbb..775a77a65 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,32 +1,35 @@ -### 3.9.1 +## 3.9.2 +* This version is focused on Windows and MacOS binary release + +## 3.9.1 * Now, releasing the latest docker image -### 3.9.0 +## 3.9.0 * Support to configure DPS as default DNS Server on Windows. * Fixed previous DNS servers restore on Mac. -### 3.8.1 +## 3.8.1 * Fixing `SIGTERM` signal wasn't being respected at Linux image -### 3.8.0 +## 3.8.0 * Now you're able to activate flags by using `1` or `true` (case insenstive), [see the docs](http://mageddo.github.io/dns-proxy-server/latest/en/3-configuration/#environment-variable-configuration). -### 3.7.0 +## 3.7.0 * Support to configure DPS as default DNS Server on MacOS, [see the docs](http://mageddo.github.io/dns-proxy-server/latest/en/1-getting-started/running-it/#running-on-mac) -### 3.6.0 +## 3.6.0 * Configure DPS at system-resolved with a custom port when is necessary * Auto DNS configurator will give up to configure after 3 failures -### 3.5.3 +## 3.5.3 * LocalSolverDB Wildcards fix: wasn't working * LocalSolverDB Case sensitive query fixes: camelCase hostnames weren't being solved -### 3.5.0 +## 3.5.0 * Final release * Add local entry `dps-sample.dev` so people can better understand how this feature works -### 3.4.0-beta +## 3.4.0-beta * DPS will detect and configure systemd-resolved when available * The default value of MG_RESOLVCONF was changed to @@ -35,55 +38,55 @@ ``` See issue [#321](https://github.com/mageddo/dns-proxy-server/issues/321) for more details. -### 3.3.0-beta -#### MG_RESOLVCONF will now accept more than one value +## 3.3.0-beta +### MG_RESOLVCONF will now accept more than one value They will separate by comma , DPS will look for each value, try to use it and stops when finds a valid value, some path which is able to configure (an existing path, with the right read and write permissions and parseable by DPS) -#### The default value of MG_RESOLVCONF was changed to +### The default value of MG_RESOLVCONF was changed to ``` /host/etc/resolv.conf,/etc/resolv.conf ``` -### 3.2.5-beta +## 3.2.5-beta * Be able to run in docker container in network host mode * When finding network by name must find with the exact name -### 3.2.3-beta +## 3.2.3-beta * Fixed docker container wasn't solving from env when the names weren't separated by ` , ` (spaces before and after the comma were needed) -### 3.2.2-beta +## 3.2.2-beta * Fixed DPS container was connecting to DPS network with wrong IP -### 3.2.1-beta +## 3.2.1-beta * Respecting OS to configure as default DNS * Other minor fixes -### 3.2.0-beta +## 3.2.0-beta * Better error treating and log formatting * TCP Server: Ensure will read the header before go to next step -### 3.1.7-beta +## 3.1.7-beta * TCP Server Partially message read fix, fixing `status=headerMsgSizeDifferentFromReadBytes!` message -### 3.1.6-beta +## 3.1.6-beta * Work only with up interfaces * Re-activate loopback interfaces -### 3.1.5-beta +## 3.1.5-beta * Fixing UDP binding server to any interface on the machine wasn't working for some clients -### 3.1.4-beta +## 3.1.4-beta * Binding UDP server to any interface on the machine * Fallback to 127.0.0.1 interface when the real one is missing -### 3.1.3-beta +## 3.1.3-beta * Doc adjustments * Fixing doc broken pages due hugo previous upgrade * Fixing docker container wildcard solving * Prioritize to [solve bridge networks over overlay ones](https://github.com/mageddo/dns-proxy-server/blob/cce3926837add0ea661648cd534c9a1192d171e1/src/test/java/com/mageddo/dnsproxyserver/docker/DockerServiceTest.java#L52) -### 3.1.2-beta +## 3.1.2-beta DPS 3 - Minor fixes * Timed out remote servers responses are being cached, it cant happen, when its a timeout cant cache but when the record really dont exists, like AAAA for bookmarks.mageddo.com must cache. @@ -91,221 +94,223 @@ DPS 3 - Minor fixes * Log level not being respected, at least no when running in native image binary * Removed quarkus splash logo -### 3.1.1-beta +## 3.1.1-beta * Fixing reponse warning `;; Warning: query response not set` -### 3.1.0-beta +## 3.1.0-beta * TCP Protocol support -### 3.0.4-beta +## 3.0.4-beta * Generating new distributions binaries * aarch64 aside docker image * uber jar, target jvm = 17 for now -### 3.0.2-beta +## 3.0.2-beta * Fixed home page was pointing to wrong place -### 3.0.1-beta +## 3.0.1-beta * DPS has your code totally refactored by maintaining the previous features, it's a structuring for new features See details at [DNS Proxy Server 3 #267](https://github.com/mageddo/dns-proxy-server/issues/267) -### 2.19.0 +## 2.19.0 * Support for absolute paths on config files (#188) -### 2.18.7 +## 2.18.7 * Fixing docker image on latest version wasn't being updated -### 2.18.6 +## 2.18.6 * Fixing gateway IP resolution when not in DPS network (#186) -### 2.18.5 +## 2.18.5 * Fixing unnecessary stacktraces were being logged * Answering NXDOMAIN when no answers were found * Fixing logging file trace -### 2.18.4 +## 2.18.4 * Bumping github-cli to fix releasing -### 2.18.3 +## 2.18.3 * Resolving docker services using configured DPS domain * Fix presence check of config setting "domain" * Adding working around coordinates for resolv.conf at the docs * Fixing releasing -### 2.18.2 +## 2.18.2 * Fixing wrong mapping on `logLevel` property -### 2.18.1 +## 2.18.1 * Change log level before try to log something -### 2.18.0 +## 2.18.0 * Feature: Multiple environments, now you can setup a group of hostnames and save it to a environment, then you can create a new environment and switch between them, very useful when working on different contexts switching from QA to PROD, for example, [see the docs](http://mageddo.github.io/dns-proxy-server/2.18/en/2-features/multiple-environments/) -### 2.17.4 +## 2.17.4 * Clearing cache for resolvers when the config file is saved -### 2.17.3 +## 2.17.3 * Separating the build image from final image, removing unnecessary bash command -### 2.17.2 +## 2.17.2 * Fixing docker build was using deprecated apt-get option -### 2.17.1 +## 2.17.1 * Reducing docker image size by 20%~ -### 2.17.0 +## 2.17.0 * Go version upgrade from 1.11 to 1.12 -### 2.16.0 +## 2.16.0 * Upgrading docker images to debian-10-slim * Reducing up to 30% on image size -### 2.15.0 +## 2.15.0 * Decreasing chance of acl issues by giving priority to answer ip of bridge networks over overlay ones * Now DPS can have your own network this way it can access and be accessed by all docker containers, **not** enabled by default [see the docs](http://mageddo.github.io/dns-proxy-server/2.15/en/2-features/dps-network-resolution/) -### 2.14.6 +## 2.14.6 * Fixing ping slowness -### 2.14.5 +## 2.14.5 * Fixing docker hub push -### 2.14.4 +## 2.14.4 * Fixing log level wasn't being respected -### 2.14.2 +## 2.14.2 * Ability to specify remote server port * Introducing storage api v2 * Refactoring the docs to use Hugo templates -### 2.14.1 +## 2.14.1 * Fixing nil pointer when remote server get timeout (#126) * Simplify bug report * Fixing nil pointer when remote server returns timeout -### 2.14.0 +## 2.14.0 * Making some refactoring facilitating to the feature requested at #121 * Fixing nil pointer sometimes when the hostname were not found -### 2.13.2 +## 2.13.2 * Fixing broken answer when hostname is not found * Fixing ping slowness -### 2.13.1 +## 2.13.1 * Make sure value column will not break the table (#116) -### 2.13.0 +## 2.13.0 * Support for CNAME on local entries, [see the docs](https://github.com/mageddo/dns-proxy-server/blob/7dacc2c/docs/features.md#manager-customer-dns-records) -### 2.12.0 +## 2.12.0 * Possibility to change container hostname domain, [see the docs](https://github.com/mageddo/dns-proxy-server/blob/70a0ff8/docs/features.md#access-container-by-its-container-name--service-name) -### 2.11.0 +## 2.11.0 * Now you can customize host machine hostname, see [the docs](https://github.com/mageddo/dns-proxy-server/blob/fa1e044b/docs/features.md#solve-host-machine-ip-from-anywhere) * Increased default loglevel to INFO -### 2.10.3 +## 2.10.3 * Build arm images on travis cause docker hub haven't support -### 2.10.2 +## 2.10.2 * Fixing binaries were generated for wrong arch -### 2.10.1 +## 2.10.1 * Official support for ARM -### 2.9.1 +## 2.9.1 * Supporting Multilevel wildcard * Fixing ping slowness, bug introduced on **2.9.0** -### 2.9.0 +## 2.9.0 * Now remote resolved names are cached respecting TTL * Refactored local storage cache -### 2.8.0 +## 2.8.0 * If your container have multiple networks you can specify which network to use when solving IP by specifying `dps.network` label -### 2.7.0 +## 2.7.0 * Now you can access your container by its container / docker-compose service name, syntax is `.docker` -### 2.6.1 +## 2.6.1 * Updating docs -### 2.6.0 +## 2.6.0 * Now you can solve host machine IP from anywhere using host `host.docker` -### 2.5.4 +## 2.5.4 * Organize some logs and auto reconfigure as default dns if resolvconf changes -### 2.5.3 +## 2.5.3 * Fixing wildcard resolution were not solving main domain to local configuration, just the subdomains -### 2.5.2 +## 2.5.2 * Fixing log level that stopped of work after **2.5.0** * Fixing and increasing docs development instructions * Fixing wildcard resolution were not solving main domain to docker container, just the subdomains -### 2.5.1 +## 2.5.1 * Fixing ping slowness, takes more than 10 seconds to respond -### 2.5.0 +## 2.5.0 * Migrate to static logging tool -### 2.4.1 +## 2.4.1 * Service restart command was with typo -### 2.4.0 +## 2.4.0 * Enable/Disable log/set log path using `MG_LOG_FILE` env or `--log-file` command line option or json config * Change log level using `MG_LOG_LEVEL` env or `--log-level` command line option or json config -### 2.3.3 +## 2.3.3 * Domains wildcard support If you register a hostname with `.` at start, then all subdomains will solve to that container/local storage entry -### 2.2.3 +## 2.2.3 * Some times container hostname don't get registered at machine startup -### 2.2.2 +## 2.2.2 * Cache Rest API v1 is exposed -### 2.2.1 +## 2.2.1 * Preventing nil pointer when container inspection fails -### 2.2.0 +## 2.2.0 * Increased code coverage * Implementing cache at local hostnames and remote server resolution * Considering TTL to invalidate hostname cache for local resolution -### 2.1.7 +## 2.1.7 * All build and release process is made inside docker (no travis dependency) -### 2.1.6 +## 2.1.6 * Refactor project structure to save dependencies in vendor folder -### 2.1.5 +## 2.1.5 * Automating build with Travis -### 2.1.1 +## 2.1.1 * Fix - `Error response from daemon: No such container...` message. see #29 * Fix - hostname don't get removed when the container has killed. see #26 -### 2.1.0 +## 2.1.0 * Turn publish port optional when running as service using docker mode -### 2.0.21 +## 2.0.21 * BugFix - Service stopped of work in normal mode -### 2.0.20 +## 2.0.20 * Support for --version option that shows the current version * Docker Compose is not required anymore to run DNS Proxy Server as a docker service -### 2.0.19 +## 2.0.19 * Ability to customize remote server * Fixing DNS solution order from (local, docker, remote) to (docker, local, remote) * Now, at least docker 1.9 API v1.21 is necessary -### 2.0.18 +## 2.0.18 * Making it compatible with docker 1.8 api v1.20 +## Notes +* compliance with: https://keepachangelog.com/en/1.0.0/ diff --git a/build.gradle b/build.gradle index 437ae483c..7a40c4c6d 100644 --- a/build.gradle +++ b/build.gradle @@ -164,3 +164,15 @@ def updateVersion(fileName, pattern, version) { w << text.replaceAll(pattern, version) } } + +task setVersionOnActions() { + doLast { + appendAppVersion(System.getenv("GITHUB_ENV")) + appendAppVersion(System.getenv("GITHUB_OUTPUT")) + } +} + +void appendAppVersion(String f) { + println("> writing ${project.version} to $f") + file(f).append("APP_VERSION=${project.version}\n") +} diff --git a/builder.bash b/builder.bash index f702c4cce..2c9e38661 100755 --- a/builder.bash +++ b/builder.bash @@ -41,8 +41,11 @@ validateRelease(){ case $1 in - copy ) - copyFileFromService build-frontend /static ./src/main/resources/META-INF/resources/static + copy-from-docker-service ) + service=$2 + from=$3 + to=$4 + copyFileFromService ${service} ${from} ${to} ;; validate-release ) @@ -88,7 +91,7 @@ case $1 in echo "> Backend build done ${IMAGE_SERVICE_NAME}" ;; - compress-upload-artifacts ) + compress-artifacts ) echo "> compress the files ..." ./builder.bash validate-release || exit 0 @@ -105,10 +108,8 @@ case $1 in echo "> compressed ${artPath} to ${tgz} ..." done - echo "> Uploading the release artifacts" - cd $REPO_DIR - DESC=$(cat RELEASE-NOTES.md | awk 'BEGIN {RS="|"} {print substr($0, 0, index(substr($0, 3), "###"))}' | sed ':a;N;$!ba;s/\n/\\r\\n/g') - github-cli release mageddo dns-proxy-server $APP_VERSION $CURRENT_BRANCH "${DESC}" ${COMPRESSED_ARTIFACTS_DIR}/*.tgz + echo "> done! files compressed to ${COMPRESSED_ARTIFACTS_DIR}" + ls -lhS ${COMPRESSED_ARTIFACTS_DIR} ;; @@ -116,8 +117,9 @@ case $1 in echo "> Push docker images to docker hub" docker tag defreitas/dns-proxy-server:${APP_VERSION} defreitas/dns-proxy-server:latest &&\ echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin &&\ - docker-compose push image-linux-amd64 image-linux-aarch64 &&\ + docker-compose push image-linux-amd64 &&\ docker push defreitas/dns-proxy-server:latest + echo "Push done" ;; deploy ) @@ -126,15 +128,29 @@ case $1 in rm -vrf build ls -lhS - ./builder.bash validate-release || exit 0 - + ./builder.bash validate-release ./builder.bash build-frontend - ./builder.bash build-backend amd64 #also builds the jar - ./builder.bash build-backend aarch64 - ./builder.bash compress-upload-artifacts + # also builds the jar + ./builder.bash build-backend amd64 + + ./builder.bash compress-artifacts ./builder.bash docker-push + + echo "> deploy done" + ;; + + deploy-arm ) + + echo "> Arm deploy started , current branch=$CURRENT_BRANCH" + ls -lhS build/* + + ./builder.bash build-backend aarch64 + ./builder.bash compress-artifacts + ./builder.bash docker-push + + echo "> arm deploy done" ;; deploy-docs ) diff --git a/docker-compose-deploy.yml b/docker-compose-deploy.yml index 1cb703660..ae95ec5bd 100644 --- a/docker-compose-deploy.yml +++ b/docker-compose-deploy.yml @@ -4,10 +4,18 @@ services: build: context: . dockerfile: Dockerfile.deploy - command: /bin/builder.bash deploy + command: | + bash -c ' + /bin/builder.bash deploy &&\ + echo "> Copying files to the host" &&\ + cp -rv /app/build/compressed-artifacts /host/build/ &&\ + cp -rv /app/build/artifacts /host/build/ &&\ + echo "Linux amd64 is done!" + ' volumes: - /var/run/docker.sock:/var/run/docker.sock - /var/lib/docker:/var/lib/docker + - ./build:/host/build environment: - CURRENT_BRANCH=${CURRENT_BRANCH} - REPO_TOKEN=${REPO_TOKEN} diff --git a/gradle.properties b/gradle.properties index 9e4100c11..2a2987945 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=3.9.1 +version=3.9.2