Skip to content

Commit

Permalink
feat: build and publish binaries on release by using make and action-…
Browse files Browse the repository at this point in the history
…gh-release
  • Loading branch information
kurokobo committed Mar 7, 2023
1 parent 3c0278f commit 51fc748
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
release:
types: [published]

permissions:
contents: write

jobs:
promote:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -67,3 +70,30 @@ jobs:
with:
src: ghcr.io/${{ github.repository }}:${{env.TAG}}
dst: quay.io/${{ github.repository }}:${{env.FLOATING_TAG}}

publish:
runs-on: ubuntu-latest
env:
VERSION: ${{github.event.release.tag_name}}
steps:
- name: Checkout Receptor
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v3

- name: Build packages
run: |
make build-package GOOS=linux GOARCH=amd64 BINNAME=receptor
make build-package GOOS=linux GOARCH=arm64 BINNAME=receptor
make build-package GOOS=darwin GOARCH=amd64 BINNAME=receptor
make build-package GOOS=darwin GOARCH=arm64 BINNAME=receptor
make build-package GOOS=windows GOARCH=amd64 BINNAME=receptor.exe
make build-package GOOS=windows GOARCH=arm64 BINNAME=receptor.exe
- name: Publish packages
uses: softprops/action-gh-release@v1
with:
files: |-
dist/checksums.txt
dist/*.tar.gz
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ kubectl
/receptorctl/venv/
.vagrant/
/docs/build
/dist
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ build-all:
go build -o receptor --tags no_controlsvc,no_backends,no_services,no_tls_config,no_workceptor,no_cert_auth ./cmd/receptor-cl && \
go build -o receptor ./cmd/receptor-cl

DIST := receptor_$(shell echo '$(VERSION)' | sed 's/^v//')_$(GOOS)_$(GOARCH)
build-package:
@echo "Building and packaging binary for $(GOOS)/$(GOARCH) as dist/$(DIST).tar.gz" && \
mkdir -p dist/$(DIST) && \
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -o dist/$(DIST)/$(BINNAME) $(DEBUGFLAGS) -ldflags "-X 'github.com/ansible/receptor/internal/version.Version=$(VERSION)'" $(TAGPARAM) ./cmd/receptor-cl && \
tar -C dist/$(DIST) -zcf dist/$(DIST).tar.gz $(BINNAME) && \
cd dist/ && sha256sum $(DIST).tar.gz >> checksums.txt

RUNTEST ?=
ifeq ($(RUNTEST),)
TESTCMD =
Expand Down Expand Up @@ -156,6 +164,7 @@ clean:
@rm -fv receptor-python-worker/dist/*
@rm -fv packaging/container/receptor
@rm -fv packaging/container/*.whl
@rm -rfv dist/
@rm -fv .container-flag*
@rm -fv .VERSION
@rm -rfv receptorctl-test-venv/
Expand Down
8 changes: 6 additions & 2 deletions docs/source/release_process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ After the draft release has been created, edit it and populate the description.

After the release is published, the `Promote Release <https://github.com/ansible/receptor/actions/workflows/promote.yml>`_ workflow will run automatically. This workflow will:

- Publish receptorctl to PyPi.
- Pull the container image from ghcr.io, re-tag, and push to quay.io.
- Publish receptorctl to `PyPI <https://pypi.org/project/receptorctl/>`_.
- Pull the container image from ghcr.io, re-tag, and push to `Quay.io <https://quay.io/repository/ansible/receptor>`_.
- Build binaries for various OSes/platforms, and attach them to the `release <https://github.com/ansible/receptor/releases>`_.

.. note::
To customize packaging and allow for tags that do not strictly satisfy the semantic versioning given to development releases, the current workflow uses simple ``make`` to build and archive binaries, instead of specific tools for build and release.

0 comments on commit 51fc748

Please sign in to comment.