Fix slicing error when data is too short #199
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-release | |
on: | |
pull_request: | |
types: [ opened, synchronize, reopened, closed ] | |
branches: | |
- main | |
- master | |
- develop | |
push: | |
branches: | |
- main | |
- master | |
- develop | |
tags: | |
- 'v*' | |
env: | |
APP_NAME: module-core-loraraw | |
GHCR_IMAGE: ghcr.io/nubeio/module-core-loraraw | |
PLATFORMS: linux/amd64,linux/arm/v7 | |
jobs: | |
context: | |
runs-on: ubuntu-20.04 | |
outputs: | |
shouldBuild: ${{ steps.context.outputs.decision_build }} | |
shouldPublish: ${{ steps.context.outputs.decision_publish }} | |
isRelease: ${{ steps.context.outputs.isTag }} | |
afterRelease: ${{ steps.context.outputs.isAfterMergedReleasePR }} | |
sha: ${{ steps.context.outputs.commitId }} | |
version: ${{ steps.context.outputs.version }} | |
shortCommitId: ${{ steps.context.outputs.shortCommitId }} | |
fqn: ${{ env.APP_NAME }}-${{ steps.context.outputs.version }}-${{ steps.context.outputs.shortCommitId }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.NUBEIO_CI_GITHUBPROJECT_TOKEN }} | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v3 | |
with: | |
git-user-signingkey: true | |
git-commit-gpgsign: true | |
git-tag-gpgsign: true | |
git-push-gpgsign: false | |
gpg-private-key: ${{ secrets.NUBEIO_CI_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.NUBEIO_CI_GPG_PASSPHARSE }} | |
- name: Project context | |
id: context | |
uses: zero88/gh-project-context@v1 | |
with: | |
dry: false | |
defaultBranch: master | |
build: | |
runs-on: ubuntu-20.04 | |
needs: context | |
if: needs.context.outputs.shouldBuild == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.NUBEIO_CI_GITHUBPROJECT_TOKEN }} | |
services: | |
registry: | |
image: zero88/gh-registry:latest | |
ports: | |
- 5000:5000 | |
options: >- | |
-v /home/runner:/var/lib/registry | |
--name registry | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: '^1.16.6' | |
- name: Set current date as env variable | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%S')" | |
- name: Edit main.go for environment | |
env: | |
VERSION: ${{ needs.context.outputs.version }} | |
COMMIT: ${{ needs.context.outputs.shortCommitId }} | |
BUILD_DATE: ${{ steps.date.outputs.date }} | |
run: | | |
sed -i -e 's,<version>,'"${VERSION}"',' main.go | |
sed -i -e 's/<commit>/'"${COMMIT}"'/' main.go | |
sed -i -e 's/<build_date>/'"${BUILD_DATE}"'/' main.go | |
- name: Build amd64 | |
run: | | |
git config --global url."https://$GITHUB_TOKEN:x-oauth-basic@github.com/NubeIO".insteadOf "https://github.com/NubeIO" | |
go mod tidy | |
go build -o module-core-loraraw-amd64 | |
- name: Build armv7 | |
if: ${{ needs.context.outputs.isRelease == 'true' }} | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf | |
env GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ go build -o module-core-loraraw-armv7 | |
- name: Zip artifacts | |
if: ${{ needs.context.outputs.isRelease == 'true' }} | |
run: | | |
mkdir -p /tmp/zip | |
artifact=${{ needs.context.outputs.fqn }}.armv7 | |
zip -r /tmp/zip/$artifact.zip ./module-core-loraraw-armv7 | |
artifact=${{ needs.context.outputs.fqn }}.amd64 | |
zip -r /tmp/zip/$artifact.zip ./module-core-loraraw-amd64 | |
- name: Create Release | |
if: ${{ needs.context.outputs.isRelease == 'true' }} | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ needs.context.outputs.version }} | |
name: Release v${{ needs.context.outputs.version }} | |
draft: false | |
prerelease: false | |
files: | | |
/tmp/zip/*.amd64.zip | |
/tmp/zip/*.armv7.zip |