diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-08 08:34:47 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-08 08:34:47 +0000 |
commit | a60d0523c1afb6c1983b522d1477b8ef319d5b99 (patch) | |
tree | 8b268a842014cff3431e898e4b7f3e267ee7cd81 /.github | |
parent | b22078ce707d21ac17ea1727a4174c44ef57ae69 (diff) | |
parent | d410a76d7ccef826fc5b1921314f88a902f1d10c (diff) |
Merge #433
433: Releases and binaries build automation r=48d90782 a=tarampampam
This PR contains:
- [x] CI steps for automatic release distributive creation and uploading to github release
- [x] CI step for automatic docker image creation (on GitHub side, not `hub.docker.com`)
- [x] `build.sh` script removal
- [x] Binary file building in `Dockerfile` using `go build` (not `build.sh`)
- [x] Docker labels with app version and build time
- [x] `Makefile` cleaning
- [x] `./bin/rr` now do not depends from `build.sh` file and use [`composer/package-versions-deprecated`](https://github.com/composer/package-versions-deprecated) package for "self version reading"
> :warning: Steps, that must be done before merging described [here](https://github.com/spiral/roadrunner/pull/433#issuecomment-740426206)
Closes #431
Co-authored-by: paramtamtam <[email protected]>
Co-authored-by: Paramtamtam <[email protected]>
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/codeql-analysis.yml | 2 | ||||
-rw-r--r-- | .github/workflows/release.yml | 139 |
2 files changed, 140 insertions, 1 deletions
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1c90e4a4..75e40110 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -47,7 +47,7 @@ jobs: with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. + # By default, queries listed here will override any specified in a config file. # Prefix the list here with "+" to use these queries and those in the config file. # queries: ./path/to/local/query, your-org/your-repo/queries@main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..b1cd83ae --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,139 @@ +name: release + +on: + release: # Docs: <https://help.github.com/en/articles/events-that-trigger-workflows#release-event-release> + types: [published] + +jobs: + build: + name: Build for ${{ matrix.os }} (${{ matrix.arch }}, ${{ matrix.compiler }}) + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + os: [windows, freebsd, darwin] # linux, freebsd, darwin, windows + compiler: [gcc] # gcc, musl-gcc + archiver: [zip] # tar, zip + arch: [amd64] # amd64, 386 + include: + - os: linux + compiler: gcc + archiver: tar + arch: amd64 + - os: '' + compiler: musl-gcc # more info: <https://musl.libc.org/> + archiver: zip + arch: amd64 + steps: + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15.5 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Install musl + if: matrix.compiler == 'musl-gcc' + run: sudo apt-get install -y musl-tools + + - name: Download dependencies + run: go mod download # `-x` means "verbose" mode + + - name: Generate builder values + id: values + run: | + echo "::set-output name=version::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`" + echo "::set-output name=timestamp::`date +%FT%T%z`" + echo "::set-output name=binary-name::rr`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`" + + - name: Compile binary file + env: + GOOS: ${{ matrix.os }} + GOARCH: ${{ matrix.arch }} + CC: ${{ matrix.compiler }} + CGO_ENABLED: 0 + LDFLAGS: >- + -s + -X github.com/spiral/roadrunner/cmd/rr/cmd.Version=${{ steps.values.outputs.version }} + -X github.com/spiral/roadrunner/cmd/rr/cmd.BuildTime=${{ steps.values.outputs.timestamp }} + run: | + go build -trimpath -ldflags "$LDFLAGS" -o "./${{ steps.values.outputs.binary-name }}" ./cmd/rr/main.go + stat "./${{ steps.values.outputs.binary-name }}" + + - name: Generate distributive directory name + id: dist-dir + run: > + echo "::set-output name=name::roadrunner-${{ steps.values.outputs.version }}-$( + [ ${{ matrix.os }} != '' ] && echo '${{ matrix.os }}' || echo 'unknown' + )$( + [ ${{ matrix.compiler }} = 'musl-gcc' ] && echo '-musl' + )-${{ matrix.arch }}" + + - name: Generate distributive archive name + id: dist-arch + run: > + echo "::set-output name=name::${{ steps.dist-dir.outputs.name }}.$( + case ${{ matrix.archiver }} in + zip) echo 'zip';; + tar) echo 'tar.gz';; + *) exit 10; + esac + )" + + - name: Create distributive + run: | + mkdir ${{ steps.dist-dir.outputs.name }} + mv "./${{ steps.values.outputs.binary-name }}" ./${{ steps.dist-dir.outputs.name }}/ + cp ./README.md ./CHANGELOG.md ./LICENSE ./${{ steps.dist-dir.outputs.name }}/ + + - name: Pack distributive using tar + if: matrix.archiver == 'tar' + run: tar -zcf "${{ steps.dist-arch.outputs.name }}" "${{ steps.dist-dir.outputs.name }}" + + - name: Pack distributive using zip + if: matrix.archiver == 'zip' + run: zip -r -q "${{ steps.dist-arch.outputs.name }}" "${{ steps.dist-dir.outputs.name }}" + + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ steps.dist-dir.outputs.name }} + path: ${{ steps.dist-arch.outputs.name }} + if-no-files-found: error + retention-days: 30 + + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ steps.dist-arch.outputs.name }} + asset_name: ${{ steps.dist-arch.outputs.name }} + tag: ${{ github.ref }} + + docker: + name: Build docker image + runs-on: ubuntu-20.04 + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Make docker login + run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_LOGIN }}" --password-stdin + + - name: Generate builder values + id: values + run: | + echo "::set-output name=version::`echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//'`" + echo "::set-output name=timestamp::`date +%FT%T%z`" + + - name: Build image + run: | + docker build \ + --tag "spiralscout/roadrunner:${{ steps.values.outputs.version }}" \ + --build-arg "APP_VERSION=${{ steps.values.outputs.version }}" \ + --build-arg "BUILD_TIME=${{ steps.values.outputs.timestamp }}" \ + . + + - name: Push image into registry + run: docker push "spiralscout/roadrunner:${{ steps.values.outputs.version }}" |