Skip to content

Commit

Permalink
Upgrade 8.0 (#6)
Browse files Browse the repository at this point in the history
* Update release.yml
* Update go.mod
* update build.sh to follow migration to mono-repo
* Use mmctl 7.10.4 version
* call make dist instead of make build
* Update build script
* Upgrade GO_VERSION to 1.19
  • Loading branch information
remiheens committed Sep 19, 2023
1 parent eba6ccc commit 18f7c89
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 80 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
branches: [ main ]

env:
DEBIAN_RELEASE: buster
DEBIAN_RELEASE: bookworm
DOCKER_PWD: /root
DOCKER_IMAGE: debian:${DEBIAN_RELEASE}
GO_VERSION: 1.19.9
Expand All @@ -29,7 +29,8 @@ jobs:
- name: Set environment from runtime properties
run: |
echo "MATTERMOST_RELEASE=$(grep 'mattermost-server' dependabot/go.mod | cut -d' ' -f2)" >> $GITHUB_ENV
echo "MMCTL_RELEASE=v7.10.0" >> $GITHUB_ENV
echo "MMCTL_RELEASE=v7.10.4" >> $GITHUB_ENV
echo "MM_FOCALBOARD_RELEASE=v7.10.4" >> $GITHUB_ENV
- name: Pull docker image
run: 'docker pull "${{ env.DOCKER_IMAGE }}"'
Expand All @@ -38,7 +39,7 @@ jobs:
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: docker run --mount="type=bind,source=$PWD,destination=${{ env.DOCKER_PWD }}" --rm=true --tty=true --workdir="${{ env.DOCKER_PWD }}" -e DEBIAN_RELEASE -e MATTERMOST_RELEASE -e MMCTL_RELEASE -e GOOS -e GOARCH "${{ env.DOCKER_IMAGE }}" ./build.sh
run: docker run --mount="type=bind,source=$PWD,destination=${{ env.DOCKER_PWD }}" --rm=true --tty=true --workdir="${{ env.DOCKER_PWD }}" -e DEBIAN_RELEASE -e MATTERMOST_RELEASE -e MMCTL_RELEASE -e MM_FOCALBOARD_RELEASE -e GOOS -e GOARCH "${{ env.DOCKER_IMAGE }}" ./build.sh

- name: Tag release
if: github.ref == 'refs/heads/main'
Expand All @@ -65,4 +66,4 @@ jobs:
tag_name: ${{ env.MATTERMOST_RELEASE }}
files: |
mattermost-${{ env.MATTERMOST_RELEASE }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz
mattermost-${{ env.MATTERMOST_RELEASE }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz.sha512sum
mattermost-${{ env.MATTERMOST_RELEASE }}-${{ matrix.os }}-${{ matrix.arch }}.tar.gz.sha512sum
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
volumes
secrets/*
docker-compose.yml
build
build

.wget-hsts
go*.tar.gz*
.env
.bash_history
29 changes: 0 additions & 29 deletions build-release.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,3 @@ index faa027239..df40f0c68 100644
cp -RL fonts $(DIST_PATH)
cp -RL templates $(DIST_PATH)
rm -rf $(DIST_PATH)/templates/*.mjml $(DIST_PATH)/templates/partials/
@@ -159,8 +159,8 @@ else
cp $(GOBIN)/$(CURRENT_PACKAGE_ARCH)/$(MM_BIN_NAME) $(DIST_PATH_GENERIC)/bin # from cross-compiled bin dir
endif

- #Download MMCTL for $(MMCTL_PLATFORM)
- scripts/download_mmctl_release.sh $(MMCTL_PLATFORM) $(DIST_PATH_GENERIC)/bin
+ @#Copy cross-compiled MMCTL
+ cp "${HOME}/go/src/github.com/mattermost/mmctl/mmctl" $(DIST_PATH_GENERIC)/bin

ifeq ("darwin_arm64","$(CURRENT_PACKAGE_ARCH)")
echo "No plugins yet for $(CURRENT_PACKAGE_ARCH) platform, skipping..."
@@ -194,17 +194,6 @@ else
done
endif

- @# Products
-
- @if [ -d $(BUILD_BOARDS_DIR) ] ; then \
- echo "Copying web app files for Boards product"; \
- mkdir -p $(DIST_PATH_GENERIC)/client/products/boards; \
- cp -R $(BUILD_BOARDS_DIR)/mattermost-plugin/webapp/dist/* $(DIST_PATH_GENERIC)/client/products/boards/; \
- else \
- echo "Unable to find files for Boards product. Please ensure that the Focalboard repository is checked out alongside the server and run 'make build-product' in it."; \
- exit 1; \
- fi
-
package-osx-amd64: package-prep
DIST_PATH_GENERIC=$(DIST_PATH_OSX_AMD64) CURRENT_PACKAGE_ARCH=darwin_amd64 PLUGIN_ARCH=osx-amd64 MMCTL_PLATFORM="Darwin-x86_64" MM_BIN_NAME=mattermost $(MAKE) package-general
@# Package
82 changes: 38 additions & 44 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ set -eux
BUILD_USER_HOME="${BUILD_USER_HOME:-/build}"
BUILD_USER_NAME="${BUILD_USER_NAME:-build}"
# Debian release used during build
DEBIAN_RELEASE="${DEBIAN_RELEASE:-stretch}"
DEBIAN_RELEASE="${DEBIAN_RELEASE:-bookworm}"
# Mattermost version to build
MATTERMOST_RELEASE="${MATTERMOST_RELEASE:-v5.26.0}"
MMCTL_RELEASE="${MMCTL_RELEASE:-v5.26.0}"
MM_FOCALBOARD_RELEASE="${MM_FOCALBOARD_RELEASE:-v5.26.0}"
# golang version
GO_VERSION="${GO_VERSION:-1.18.1}"
GO_VERSION="${GO_VERSION:-1.19.9}"

if [ "$(id -u)" -eq 0 ]; then # as root user
# create build user, if needed
Expand Down Expand Up @@ -41,21 +42,28 @@ if [ "$(id -u)" -eq 0 ]; then # as root user
apt-get update
# install dependencies
apt-get install --quiet \
wget build-essential patch git python2
wget build-essential patch git python3
# install 'pngquant' build dependencies (required by node module)
apt-get build-dep --quiet \
pngquant
# install go from golang.org
wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz
tar -xvf go${GO_VERSION}.linux-amd64.tar.gz
mv go /usr/local
if [ ! -f go${GO_VERSION}.linux-amd64.tar.gz ]; then
wget https://golang.org/dl/go${GO_VERSION}.linux-amd64.tar.gz
fi
if [ ! -d /usr/local/go ]; then
tar -xvf go${GO_VERSION}.linux-amd64.tar.gz
mv go /usr/local
fi
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$PATH
# FIXME go (executed by build user) writes to GOROOT
install --directory --owner="${BUILD_USER_NAME}" \
"$(go env GOROOT)/pkg/$(go env GOOS)_$(go env GOARCH)"

echo "GOOS_GOARCH=$(go env GOOS)_$(go env GOARCH)"
# Re-invoke this build.sh script with the 'build' user
runuser -u "${BUILD_USER_NAME}" -- "${0}"

# salvage build artifacts
cp --verbose \
"${BUILD_USER_HOME}/mattermost-${MATTERMOST_RELEASE}-$(go env GOOS)-$(go env GOARCH).tar.gz" \
Expand All @@ -74,80 +82,66 @@ export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

# download and extract Mattermost sources
for COMPONENT in server webapp; do
install --directory "${HOME}/go/src/github.com/mattermost/mattermost-${COMPONENT}"
wget --quiet --continue --output-document="mattermost-${COMPONENT}.tar.gz" \
"https://github.com/mattermost/mattermost-${COMPONENT}/archive/${MATTERMOST_RELEASE}.tar.gz"
tar --directory="${HOME}/go/src/github.com/mattermost/mattermost-${COMPONENT}" \
--strip-components=1 --extract --file="mattermost-${COMPONENT}.tar.gz"
done
install --directory "${HOME}/go/src/github.com/mattermost/mattermost"
wget --quiet --continue --output-document="mattermost.tar.gz" \
"https://github.com/mattermost/mattermost/archive/${MATTERMOST_RELEASE}.tar.gz"
tar --directory="${HOME}/go/src/github.com/mattermost/mattermost" \
--strip-components=1 --extract --file="mattermost.tar.gz"

# download and extract focalboard
install --directory "${HOME}/go/src/github.com/mattermost/focalboard"
wget --quiet --continue --output-document="focalboard.tar.gz" \
"https://github.com/mattermost/focalboard/archive/${MATTERMOST_RELEASE}.tar.gz"
tar --directory="${HOME}/go/src/github.com/mattermost/focalboard" \
--strip-components=1 --extract --file="focalboard.tar.gz"
wget --quiet --continue --output-document="focalboard.tar.gz" \
"https://github.com/mattermost/focalboard/archive/${MM_FOCALBOARD_RELEASE}.tar.gz"
tar --directory="${HOME}/go/src/github.com/mattermost/focalboard" \
--strip-components=1 --extract --file="focalboard.tar.gz"

# install mattermost-webapp's required version of nodejs
pushd "${HOME}/go/src/github.com/mattermost/mattermost-webapp"
pushd "${HOME}/go/src/github.com/mattermost/mattermost/webapp"
nvm install
popd

# prepare the go build environment
install --directory "${HOME}/go/bin"
if [ "$(go env GOOS)_$(go env GOARCH)" != 'linux_amd64' ]; then
if [ "$(go env GOOS)_$(go env GOARCH)" != 'linux_amd64' ] && [ ! -f "${HOME}/go/bin/linux_amd64" ] && [ ! -h "${HOME}/go/bin/linux_amd64" ]; then
ln --symbolic \
"${HOME}/go/bin/$(go env GOOS)_$(go env GOARCH)" \
"${HOME}/go/bin/linux_amd64"
fi
# build mmctl
install --directory "${HOME}/go/src/github.com/mattermost/mmctl"
wget --quiet --continue --output-document="mmctl.tar.gz" \
"https://github.com/mattermost/mmctl/archive/${MMCTL_RELEASE}.tar.gz"
tar --directory="${HOME}/go/src/github.com/mattermost/mmctl" \
--strip-components=1 --extract --file="mmctl.tar.gz"
find "${HOME}/go/src/github.com/mattermost/mmctl/" -type f -name '*.go' | xargs \
sed -i \
-e 's#//go:build linux || darwin#//go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd#' \
-e 's#// +build linux darwin#// +build linux darwin dragonfly freebsd netbsd openbsd#'
make --directory="${HOME}/go/src/github.com/mattermost/mmctl" \
BUILD_NUMBER="dev-$(go env GOOS)-$(go env GOARCH)-${MMCTL_RELEASE}" \
ADVANCED_VET=0 \
GO="GOARCH= GOOS= $(command -v go)"

# build focalboard
make --directory="${HOME}/go/src/github.com/mattermost/focalboard" \
prebuild
make --directory="${HOME}/go/src/github.com/mattermost/focalboard" \
build
# build Mattermost webapp
# # build Mattermost webapp
npm set progress false
sed -i -e 's#--verbose#--display minimal#' \
"${HOME}/go/src/github.com/mattermost/mattermost-webapp/package.json"
make --directory="${HOME}/go/src/github.com/mattermost/mattermost-webapp" \
build
"${HOME}/go/src/github.com/mattermost/mattermost/webapp/package.json"
make --directory="${HOME}/go/src/github.com/mattermost/mattermost/webapp" \
dist
# build Mattermost server
patch --directory="${HOME}/go/src/github.com/mattermost/mattermost-server" \
--strip=1 -t < "${HOME}/build-release.patch"
patch --directory="${HOME}/go/src/github.com/mattermost/mattermost/server" \
--strip=1 -t < "/root/build-release.patch"
sed -i \
-e 's#go generate#env --unset=GOOS --unset=GOARCH go generate#' \
-e 's#$(GO) generate#env --unset=GOOS --unset=GOARCH go generate#' \
-e 's#PWD#CURDIR#' \
"${HOME}/go/src/github.com/mattermost/mattermost-server/Makefile" \
"${HOME}/go/src/github.com/mattermost/mattermost-server/build/release.mk"
make --directory="${HOME}/go/src/github.com/mattermost/mattermost-server" \
"${HOME}/go/src/github.com/mattermost/mattermost/server/Makefile" \
"${HOME}/go/src/github.com/mattermost/mattermost/server/build/release.mk"
make --directory="${HOME}/go/src/github.com/mattermost/mattermost/server" \
config-reset \
BUILD_NUMBER="dev-$(go env GOOS)-$(go env GOARCH)-${MATTERMOST_RELEASE}" \
GO="GOARCH= GOOS= $(command -v go)" \
PLUGIN_PACKAGES=''
make --directory="${HOME}/go/src/github.com/mattermost/mattermost-server" \
make --directory="${HOME}/go/src/github.com/mattermost/mattermost/server" \
build-linux package-linux \
BUILD_NUMBER="dev-$(go env GOOS)-$(go env GOARCH)-${MATTERMOST_RELEASE}" \
BUILD_BOARDS=0 \
BUILD_ENTERPRISE=0 \
GO="GOARCH=$(go env GOARCH) GOOS=$(go env GOOS) $(command -v go)" \
PLUGIN_PACKAGES=''
# rename archive and calculate its SHA512 sum
mv "${HOME}/go/src/github.com/mattermost/mattermost-server/dist/mattermost-team-linux-amd64.tar.gz" \
mv "${HOME}/go/src/github.com/mattermost/mattermost/server/dist/mattermost-team-linux-amd64.tar.gz" \
"${HOME}/mattermost-${MATTERMOST_RELEASE}-$(go env GOOS)-$(go env GOARCH).tar.gz"
sha512sum "${HOME}/mattermost-${MATTERMOST_RELEASE}-$(go env GOOS)-$(go env GOARCH).tar.gz" | \
tee "${HOME}/mattermost-${MATTERMOST_RELEASE}-$(go env GOOS)-$(go env GOARCH).tar.gz.sha512sum"
4 changes: 2 additions & 2 deletions dependabot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/remiheens/mattermost-docker-arm/dependabot
go 1.19

require (
github.com/mattermost/mattermost-server/v6 v7.10.0
github.com/mattermost/mattermost-server/v6 v8.0.0
github.com/mattermost/mmctl v0.0.0-20211221153052-1bb2fec4c15e
)
)

0 comments on commit 18f7c89

Please sign in to comment.