| # 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. |
| |
| name: release |
| |
| on: |
| push: |
| tags: |
| - "v*" |
| branches-ignore: |
| - "**" |
| |
| permissions: |
| contents: write |
| |
| env: |
| PROJECT_NAME: openserverless-cli |
| |
| jobs: |
| test: |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout |
| uses: actions/checkout@v5 |
| - name: Check Dependencies' License |
| uses: apache/skywalking-eyes/dependency@v0.9.0 |
| - name: Set up Go |
| uses: actions/setup-go@v6 |
| with: |
| go-version: '>=1.22.5' |
| - name: Setup upstream repo |
| run: | |
| if test -n "$CUSTOM_REPO" |
| then echo "$CUSTOM_REPO" >repo.txt |
| else echo "CUSTOM_REPO not set, keeping repo.txt: $(cat repo.txt)" |
| fi |
| env: |
| CUSTOM_REPO: ${{vars.CUSTOM_REPO}} |
| - name: Build and Test CLI |
| 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 |
| |
| build: |
| needs: test |
| runs-on: ubuntu-latest |
| strategy: |
| fail-fast: false |
| matrix: |
| include: |
| - goos: linux |
| goarch: amd64 |
| - goos: linux |
| goarch: arm64 |
| - goos: darwin |
| goarch: amd64 |
| - goos: darwin |
| goarch: arm64 |
| - goos: windows |
| goarch: amd64 |
| steps: |
| - name: Checkout |
| uses: actions/checkout@v5 |
| - name: Set up Go |
| uses: actions/setup-go@v6 |
| with: |
| go-version: '>=1.22.5' |
| - name: Setup upstream repo |
| run: | |
| if test -n "$CUSTOM_REPO" |
| then echo "$CUSTOM_REPO" >repo.txt |
| else echo "CUSTOM_REPO not set, keeping repo.txt: $(cat repo.txt)" |
| fi |
| env: |
| CUSTOM_REPO: ${{vars.CUSTOM_REPO}} |
| - name: Build and package |
| env: |
| CGO_ENABLED: "0" |
| GOOS: ${{ matrix.goos }} |
| GOARCH: ${{ matrix.goarch }} |
| run: | |
| set -e |
| VERSION="$(cat version.txt)" |
| BASE="${PROJECT_NAME}_${VERSION}_${GOOS}_${GOARCH}" |
| mkdir -p dist/"$BASE" |
| if test "$GOOS" = "windows" |
| then BIN=ops.exe |
| else BIN=ops |
| fi |
| go build -o dist/"$BASE"/$BIN ./cmd/ops |
| cp LICENSE NOTICE DISCLAIMER dist/"$BASE"/ |
| cd dist |
| if test "$GOOS" = "windows" |
| then zip -r "$BASE.zip" "$BASE" |
| else tar czf "$BASE.tar.gz" "$BASE" |
| fi |
| rm -rf "$BASE" |
| - name: Upload artifact |
| uses: actions/upload-artifact@v7 |
| with: |
| name: dist-${{ matrix.goos }}-${{ matrix.goarch }} |
| path: dist/* |
| if-no-files-found: error |
| |
| release: |
| needs: build |
| runs-on: ubuntu-latest |
| steps: |
| - name: Checkout |
| uses: actions/checkout@v5 |
| - name: Download artifacts |
| uses: actions/download-artifact@v8 |
| with: |
| path: dist |
| pattern: dist-* |
| merge-multiple: true |
| - name: Generate checksums |
| run: | |
| set -e |
| VERSION="$(cat version.txt)" |
| cd dist |
| sha256sum * >"${PROJECT_NAME}_${VERSION}_checksums.txt" |
| ls -l |
| - name: Release |
| uses: softprops/action-gh-release@v3 |
| with: |
| files: dist/* |
| fail_on_unmatched_files: true |
| env: |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |