Skip to content

Commit

Permalink
create releases from github actions (#494)
Browse files Browse the repository at this point in the history
both github release and artifact uploads + docker build and push and tag
  • Loading branch information
ldemailly committed Nov 23, 2021
1 parent 8f354c2 commit df79f37
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 10 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@

name: Release

on:
push:
tags:
- '*'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build
id: build
run: |
make info
make release
VERSION=$(make echo-version)
echo ::set-output name=VERSION::${VERSION}
PACKAGE_VERSION=$(make echo-package-version)
echo ::set-output name=PACKAGE_VERSION::${PACKAGE_VERSION}
echo "Version $VERSION, Package version $PACKAGE_VERSION"
- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: fortio/fortio:${{ steps.build.outputs.VERSION }}, fortio/fortio:latest

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Fortio ${{ steps.build.outputs.VERSION }}
draft: true

- name: Upload release artifact 1
id: upload-release-asset1
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: release/fortio_${{ steps.build.outputs.VERSION }}.orig.tar.gz
asset_name: fortio_${{ steps.build.outputs.VERSION }}.orig.tar.gz
asset_content_type: application/x-compressed-tar
# Todo find a way to upload all in 1... it's silly to have to do 1 by 1
- name: Upload release artifact 2
id: upload-release-asset2
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/fortio-${{ steps.build.outputs.PACKAGE_VERSION }}-1.x86_64.rpm
asset_name: fortio-${{ steps.build.outputs.PACKAGE_VERSION }}-1.x86_64.rpm
asset_content_type: application/x-rpm
- name: Upload release artifact 3
id: upload-release-asset3
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/fortio-linux_x64-${{ steps.build.outputs.VERSION }}.tgz
asset_name: fortio-linux_x64-${{ steps.build.outputs.VERSION }}.tgz
asset_content_type: application/x-compressed-tar
- name: Upload release artifact 4
id: upload-release-asset4
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/fortio_${{ steps.build.outputs.VERSION }}_amd64.deb
asset_name: fortio_${{ steps.build.outputs.VERSION }}_amd64.deb
asset_content_type: application/vnd.debian.binary-package
- name: Upload release artifact 5
id: upload-release-asset5
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: release/fortio_win_${{ steps.build.outputs.VERSION }}.zip
asset_name: fortio_win_${{ steps.build.outputs.VERSION }}.zip
asset_content_type: application/zip
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ debug-tags:
@echo "GIT_TAG=$(GIT_TAG)"
@echo "DIST_VERSION=$(DIST_VERSION)"

echo-version:
@echo "$(DIST_VERSION)"

# FPM (for rpm...) converts - to _
echo-package-version:
@echo "$(DIST_VERSION)" | sed -e "s/-/_/g"

# Putting spaces in linker replaced variables is hard but does work.
# This sets up the static directory outside of the go source tree and
# the default data directory to a /var/lib/... volume
Expand Down Expand Up @@ -189,9 +196,9 @@ dist: release/Makefile
# put the source files where they can be used as gopath by go,
# except leave the debian dir where it needs to be (below the version dir)
git ls-files \
| awk '{printf("src/fortio.org/fortio/%s\n", $$0)}' \
| (cd ../../.. ; $(TAR) \
--xform="s|^src|fortio-$(DIST_VERSION)/src|;s|^.*debian/|fortio-$(DIST_VERSION)/debian/|" \
| awk '{printf("fortio/%s\n", $$0)}' \
| (cd ../ ; $(TAR) \
--xform="s|^fortio/|fortio-$(DIST_VERSION)/src/fortio.org/fortio/|;s|^.*debian/|fortio-$(DIST_VERSION)/debian/|" \
--owner=0 --group=0 -c -f - -T -) > $(DIST_PATH)
# move the release/Makefile at the top (after the version dir)
$(TAR) --xform="s|^release/|fortio-$(DIST_VERSION)/|" \
Expand Down Expand Up @@ -255,3 +262,9 @@ debian-dist: distclean debian-dist-common
# assumes you ran one of the previous 2 target first
debian-sbuild:
cd $(TMP_DIST_DIR)/fortio-$(DIST_VERSION); sbuild

info:
@echo "GIT_SHA=$(GIT_SHA)"
@echo "GIT_TAG=$(GIT_TAG)"
pwd
ls -la
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ docker run fortio/fortio load http://www.google.com/ # For a test run
Or download one of the binary distributions, from the [releases](https://github.com/fortio/fortio/releases) assets page or for instance:

```shell
curl -L https://github.com/fortio/fortio/releases/download/v1.18.0/fortio-linux_x64-1.18.0.tgz \
curl -L https://github.com/fortio/fortio/releases/download/v1.18.1/fortio-linux_x64-1.18.1.tgz \
| sudo tar -C / -xvzpf -
# or the debian package
wget https://github.com/fortio/fortio/releases/download/v1.18.0/fortio_1.18.0_amd64.deb
dpkg -i fortio_1.18.0-1_amd64.deb
wget https://github.com/fortio/fortio/releases/download/v1.18.1/fortio_1.18.1_amd64.deb
dpkg -i fortio_1.18.1-1_amd64.deb
# or the rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.18.0/fortio-1.18.0-1.x86_64.rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.18.1/fortio-1.18.1-1.x86_64.rpm
```

On a MacOS you can also install Fortio using [Homebrew](https://brew.sh/):
Expand All @@ -61,7 +61,7 @@ On a MacOS you can also install Fortio using [Homebrew](https://brew.sh/):
brew install fortio
```

On Windows, download https://github.com/fortio/fortio/releases/download/v1.18.0/fortio_win_1.18.0.zip and extract `fortio.exe` to any location, then using the Windows Command Prompt:
On Windows, download https://github.com/fortio/fortio/releases/download/v1.18.1/fortio_win_1.18.1.zip and extract `fortio.exe` to any location, then using the Windows Command Prompt:
```
fortio.exe server
```
Expand Down Expand Up @@ -104,7 +104,7 @@ Full list of command line flags (`fortio help`):
<details>
<!-- use release/updateFlags.sh to update this section -->
<pre>
Φορτίο 1.18.0 usage:
Φορτίο 1.18.1 usage:
fortio command [flags] target
where command is one of: load (load testing), server (starts ui, http-echo,
redirect, proxies, tcp-echo and grpc ping servers), tcp-echo (only the tcp-echo
Expand Down
2 changes: 1 addition & 1 deletion release/Dockerfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ COPY docs/fortio.1 usr/share/man/man1/fortio.1
RUN mkdir /tgz
# Make sure the list here is both minimal and complete
# we could take all of * but that adds system directories to the tar
RUN tar cvf - usr/share/fortio/* usr/share/man/man1/fortio.1 usr/bin/fortio | gzip --best > /tgz/fortio-linux_x64-$(./usr/bin/fortio version -s).tgz
RUN tar cvf - usr/share/man/man1/fortio.1 usr/bin/fortio | gzip --best > /tgz/fortio-linux_x64-$(./usr/bin/fortio version -s).tgz
COPY --from=build /go/src/fortio.org/fortio.exe usr/share/fortio/
WORKDIR /stage/usr/share/fortio
RUN zip -9 -r fortio_win_$(/stage/usr/bin/fortio version -s).zip fortio.exe && mv *.zip /tgz
Expand Down

0 comments on commit df79f37

Please sign in to comment.