Skip to content

Commit

Permalink
Changed go releaser to create zip and tar archives instead of binarie…
Browse files Browse the repository at this point in the history
…s with all dependencies packgaed in

Signed-off-by: Corbin Phelps <[email protected]>
  • Loading branch information
Corbin Phelps committed Mar 7, 2022
1 parent 333e3cd commit 7d46b54
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 19 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: release
on:
push:
tags:
- 'v*'
- "v*"

jobs:
build-msi:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
echo "C:/build" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
# Installs go-msi and wix.
- name: Install Build Tools
run: |
run: |
curl -f -L -o go-msi.exe https://github.com/observIQ/go-msi/releases/download/v2.1.0/go-msi.exe
curl -f -L -o wix310-binaries.zip http://wixtoolset.org/downloads/v3.10.3.3007/wix310-binaries.zip
unzip wix310-binaries.zip
Expand Down Expand Up @@ -191,7 +191,10 @@ jobs:
run: 'echo "$COSIGN_PRIVATE_KEY" >> cosign.key'
shell: bash
env:
COSIGN_PRIVATE_KEY : ${{secrets.ORG_COSIGN_PRIVATE_KEY}}
COSIGN_PRIVATE_KEY: ${{secrets.ORG_COSIGN_PRIVATE_KEY}}
# Prep dependencies needed release archiving
- name: Preparing Release Dependencies
run: make release-prep
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ windows/**/wix.dynamic.json
windows/**/wix
stanza-plugins
windows/config.yaml
windows/opentelemetry-java-contrib-jmx-metrics.jar
opentelemetry-java-contrib-jmx-metrics.jar
plugins
release_deps
23 changes: 18 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://goreleaser.com/customization/build/
builds:
- id: collector
binary: collector_{{ .Os }}_{{ .Arch }}
binary: observiq-collector
main: ./cmd/collector
env:
- CGO_ENABLED=0
Expand All @@ -28,10 +28,23 @@ builds:

# https://goreleaser.com/customization/archive/
archives:
- builds:
- collector
# skip archiving as tar.gz / zip
format: binary
- format: tar.gz
name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}"
files:
- LICENSE
- src: release_deps/opentelemetry-java-contrib-jmx-metrics.jar
dst: "."
strip_parent: true
- src: release_deps/config.yaml
dst: "."
strip_parent: true
- src: release_deps/plugins/*
dst: plugins
strip_parent: true

format_overrides:
- goos: windows
format: zip

# https://goreleaser.com/customization/checksum/
checksum:
Expand Down
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,22 @@ add-license:
echo "Add License finished successfully"; \
fi

# Downloads and setups dependencies that are packaged with binary
.PHONY: release-prep
release-prep:
@rm -rf release_deps
@mkdir release_deps
./buildscripts/download-dependencies.sh release_deps
@cp config/example.yaml release_deps/config.yaml

# Build, sign, and release
.PHONY: release
release:
release: release-prep
goreleaser release --parallelism 4 --rm-dist

# Build and sign, skip release and ignore dirty git tree
.PHONY: release-test
release-test:
release-test: release-prep
goreleaser release --parallelism 4 --skip-validate --skip-publish --rm-dist

.PHONY: for-all
Expand Down
10 changes: 9 additions & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ Releases are managed through GitHub releases. The steps to create a release are
- Attach binaries to the GitHub release
- Mark the release as a full release once it is finished.

4. Done! The collector is released
4. Done! The collector is released

# Testing Release locally

In order to run the `make release-test` you need to setup the following in your environment:

1. Run `make install-tools`
2. Setup a github token per [goreleaser instructions](https://goreleaser.com/scm/github/#api-token)
3. Run `make release-test`
15 changes: 10 additions & 5 deletions buildscripts/download-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,25 @@ set -e

DOWNLOAD_DIR="${1:-.}"
START_DIR=$PWD
BASEDIR="$(dirname "$(realpath "$0")")"
BASEDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PROJECT_BASE="$BASEDIR/.."
PLUGIN_VERSION="$(cat "$PROJECT_BASE/PLUGINS_VERSION")"
JAVA_CONTRIB_VERSION="$(cat "$PROJECT_BASE/JAVA_CONTRIB_VERSION")"

echo "Retrieving java contrib at $JAVA_CONTRIB_VERSION"
curl -fL -o "$DOWNLOAD_DIR/opentelemetry-java-contrib-jmx-metrics.jar" \
"https://github.com/open-telemetry/opentelemetry-java-contrib/releases/download/$(cat "$PROJECT_BASE/JAVA_CONTRIB_VERSION")/opentelemetry-jmx-metrics.jar"
"https://github.com/open-telemetry/opentelemetry-java-contrib/releases/download/$(cat "$PROJECT_BASE/JAVA_CONTRIB_VERSION")/opentelemetry-jmx-metrics.jar" > /dev/null 2>&1


echo "Retrieving stanza-plugs at commit $PLUGIN_VERSION"
if [ ! -d "$DOWNLOAD_DIR/stanza-plugins" ]; then
git clone [email protected]:observIQ/stanza-plugins.git "$DOWNLOAD_DIR/stanza-plugins"
git clone [email protected]:observIQ/stanza-plugins.git "$DOWNLOAD_DIR/stanza-plugins" > /dev/null 2>&1
fi

cd "$DOWNLOAD_DIR/stanza-plugins"
git fetch --all
git checkout "$(cat "$PROJECT_BASE/PLUGINS_VERSION")"
git fetch --all > /dev/null 2>&1
git checkout $PLUGIN_VERSION > /dev/null 2>&1
cd "$START_DIR"

cp -r "$DOWNLOAD_DIR/stanza-plugins/plugins" "$DOWNLOAD_DIR"
rm -rf "$DOWNLOAD_DIR/stanza-plugins"
2 changes: 1 addition & 1 deletion windows/scripts/build-msi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

set -e
BASEDIR="$(dirname "$(realpath "$0")")"
BASEDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PROJECT_BASE="$BASEDIR/../.."

cp "$PROJECT_BASE/dist/collector_windows_amd64.exe" "observiq-collector.exe"
Expand Down
2 changes: 1 addition & 1 deletion windows/scripts/fetch-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

set -e
BASEDIR="$(dirname "$(realpath "$0")")"
BASEDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
PROJECT_BASE="$BASEDIR/../.."

[ -f go-msi.exe ] || curl -f -L -o go-msi.exe https://github.com/observIQ/go-msi/releases/download/v2.1.0/go-msi.exe
Expand Down

0 comments on commit 7d46b54

Please sign in to comment.