This is an automated email from the ASF dual-hosted git repository. sciabarracom pushed a commit to branch 0.9.0-preupdate in repository https://gitbox.apache.org/repos/asf/openserverless-cli.git
commit ac8a2835d0997ac3ac6170ede864ac200323b1e4 Author: Michele Sciabarra <[email protected]> AuthorDate: Fri Sep 4 23:56:41 2026 +0200 rewbuild --- .github/workflows/release.yml | 93 ++++++++++++++++++++++++++++++++++++------- .gitignore | 3 ++ .goreleaser.yaml | 53 ------------------------ Taskfile.yml | 22 +++++++++- dist.sh | 74 ++++++++++++++++++++++++++++++++++ 5 files changed, 175 insertions(+), 70 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5471e3b..c38b61f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,35 +23,98 @@ on: - "v*" branches-ignore: - "*" + workflow_dispatch: permissions: - contents: write + contents: read jobs: - goreleaser: + + # Tests and license compliance run before anything is published. + check: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Check Dependencies' License - uses: apache/skywalking-eyes/dependency@main # always prefer to use a revision instead of `main`. + uses: apache/skywalking-eyes/dependency@main - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '>=1.22.5' + go-version-file: go.mod - name: Run Tests run: | - ls -l - sudo sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin - task install - source ~/.bashrc - ops -version - task tests - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 + sudo sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin + task install + export PATH="$HOME/.local/bin:$PATH" + ops -version + task tests + + # Cross compile every supported platform and upload one archive each. + # Building is pure `go build`: the version is taken from the embedded + # version.txt, so no linker flags and no external release tooling. + build: + needs: check + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - goos: linux + goarch: amd64 + - goos: linux + goarch: arm64 + - goos: darwin + goarch: arm64 + - goos: windows + goarch: amd64 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Build archive + env: + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} + run: ./dist.sh + - name: Upload archive + uses: actions/upload-artifact@v4 with: - distribution: goreleaser - version: '~> v2' - args: release --clean + name: dist-${{ matrix.goos }}-${{ matrix.goarch }} + path: dist/ + if-no-files-found: error + retention-days: 1 + + # Collect the per-platform archives, checksum them together and publish. + release: + needs: build + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Download archives + uses: actions/download-artifact@v4 + with: + path: dist + pattern: dist-* + merge-multiple: true + - name: Generate checksums + run: | + cd dist + sha256sum *.tar.gz *.zip > "openserverless-cli_$(cat ../version.txt)_checksums.txt" + ls -l + - name: Publish release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.ref_name }} + run: | + gh release create "$TAG" \ + --repo "$GITHUB_REPOSITORY" \ + --title "$TAG" \ + --generate-notes \ + dist/* diff --git a/.gitignore b/.gitignore index 07e1d7d..e6ca8ea 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,6 @@ _patch/bin/task _patch/bin/gosh _patch/bin/wsk _patch/bin/openwhisk-wskdeploy + +# release archives built by dist.sh +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index 303a997..0000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,53 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -version: 2 - -builds: - - env: - - CGO_ENABLED=0 - main: ./cmd/ops - binary: ops - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 - ignore: - - goos: windows - goarch: arm64 - -archives: - - id: default - format_overrides: - - goos: windows - format: zip - name_template: >- - {{ .ProjectName }}_ - {{- .Version }}_ - {{- .Os }}_ - {{- .Arch }} - -changelog: - sort: asc - filters: - include: - - "^add:" - - "^fix:" - - "^change:" diff --git a/Taskfile.yml b/Taskfile.yml index ccfe59c..4812c2f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -40,14 +40,31 @@ tasks: - git tag -f "v$(cat version.txt)" - trigger: - desc: create tag and push triggering a build + ci: + aliases: [trigger] + desc: create tag and push it, triggering the release build in GitHub Actions prompt: did you commit everyting? cmds: - git diff --exit-code - task: tag - git push origin main --tags + dist: + desc: build one release archive (GOOS=<os> GOARCH=<arch>, defaults to host) + cmds: + - ./dist.sh + + dist-all: + desc: build the release archives for all supported platforms into dist/ + cmds: + - rm -rf dist + - GOOS=linux GOARCH=amd64 ./dist.sh + - GOOS=linux GOARCH=arm64 ./dist.sh + - GOOS=darwin GOARCH=arm64 ./dist.sh + - GOOS=windows GOARCH=amd64 ./dist.sh + - cd dist && sha256sum *.tar.gz *.zip > "openserverless-cli_$(cat ../version.txt)_checksums.txt" + - ls -l dist + rebuild: - rm -f ops - task: build @@ -137,6 +154,7 @@ tasks: clean: - rm ops || true + - rm -rf dist - go clean -cache -modcache -testcache -fuzzcache utestdiff: diff --git a/dist.sh b/dist.sh new file mode 100755 index 0000000..e16d74a --- /dev/null +++ b/dist.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Build one release archive for a single platform. +# +# The platform is selected with the standard Go environment variables: +# +# GOOS=linux GOARCH=arm64 ./dist.sh +# +# and defaults to the host platform when they are unset. The result is +# +# dist/openserverless-cli_<version>_<goos>_<goarch>.tar.gz (.zip on windows) +# +# containing the `ops` binary next to LICENSE, DISCLAIMER and NOTICE. + +set -e + +cd "$(dirname "$0")" + +PROJECT="openserverless-cli" +VERSION="$(cat version.txt)" + +# Fall back to the host platform when GOOS/GOARCH are not set. +GOOS="${GOOS:-$(go env GOOS)}" +GOARCH="${GOARCH:-$(go env GOARCH)}" +export GOOS GOARCH + +# Windows gets a .exe binary in a zip; everyone else a plain binary in a tarball. +if test "$GOOS" = "windows" +then BIN="ops.exe"; EXT="zip" +else BIN="ops"; EXT="tar.gz" +fi + +NAME="${PROJECT}_${VERSION}_${GOOS}_${GOARCH}" +STAGE="dist/$NAME" + +rm -rf "$STAGE" +mkdir -p "$STAGE" + +echo "building $NAME" + +# Reproducible, statically linked, stripped: no cgo, no build paths embedded. +CGO_ENABLED=0 go build -trimpath -ldflags="-s -w" -o "$STAGE/$BIN" ./cmd/ops/ + +# Every archive ships the ASF required legal files. +cp LICENSE DISCLAIMER NOTICE README.md "$STAGE" + +# Archive from inside the staging dir so archive paths are not prefixed. +# List the members explicitly so they are stored without a "./" prefix: +# install.sh extracts a single member by name and that fails on "./ops". +FILES="LICENSE DISCLAIMER NOTICE README.md $BIN" +if test "$EXT" = "zip" +then (cd "$STAGE" && zip -q -X "../$NAME.zip" $FILES) +else (cd "$STAGE" && tar czf "../$NAME.tar.gz" $FILES) +fi + +rm -rf "$STAGE" + +ls -l "dist/$NAME.$EXT"
