-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from Kong/feat/github-releases
feat(releases): setup github releases
- Loading branch information
Showing
8 changed files
with
214 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
name: Release | ||
|
||
on: # yamllint disable-line rule:truthy | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
outputs: | ||
published: ${{ steps.release.outputs.published }} | ||
release-git-tag: ${{ steps.release.outputs.release-git-tag }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Release | ||
id: release | ||
uses: ahmadnassri/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
artifacts: | ||
needs: release | ||
name: Create Release Artifacts | ||
strategy: | ||
matrix: | ||
architecture: [aarch64, x86_64] | ||
ostype: [linux-gnu, linux-musl] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: docker/setup-qemu-action@v2 | ||
- uses: docker/setup-buildx-action@v2 | ||
- name: Set environment variables | ||
run: | | ||
echo "ARCHITECTURE=${{ matrix.architecture }}" >> $GITHUB_ENV | ||
echo "OSTYPE=${{ matrix.ostype }}" >> $GITHUB_ENV | ||
echo "REGISTRY=ghcr.io" | ||
- name: Build, and Package | ||
run: make build/package | ||
- name: Log in to the Container registry | ||
if: ${{ needs.release.outputs.published == 'true' }} | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Docker meta | ||
if: ${{ needs.release.outputs.published == 'true' }} | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ghcr.io/kong/template-github-release | ||
sep-tags: ' ' | ||
flavor: | | ||
suffix=-${{ matrix.architecture }}-${{ matrix.ostype }} | ||
tags: | | ||
type=sha | ||
type=ref,event=branch | ||
type=semver,value=${{ needs.release.outputs.release-git-tag }} | ||
- name: Retag and Push | ||
if: ${{ needs.release.outputs.published == 'true' }} | ||
run: | | ||
for tag in ${{ steps.meta.outputs.tags }}; do \ | ||
docker tag ghcr.io/template-github-release:build-$ARCHITECTURE-$OSTYPE $tag && \ | ||
docker push $tag; \ | ||
done | ||
- name: Archive the package | ||
if: ${{ needs.release.outputs.published == 'true' }} | ||
run: | | ||
tar -C package -czvf ${{ matrix.architecture }}-${{ matrix.ostype }}.tar.gz . | ||
- name: Add Release Artifact to the Github Release | ||
if: ${{ needs.release.outputs.published == 'true' }} | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ needs.release.outputs.release-git-tag }} | ||
files: ${{ matrix.architecture }}-${{ matrix.ostype }}.tar.gz |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"branches": ["main"], | ||
"tagFormat": "${version}", | ||
"repositoryUrl": "https://github.com/kong/template-github-release.git", | ||
"plugins": [ | ||
[ | ||
"@semantic-release/commit-analyzer", | ||
{ | ||
"preset": "conventionalcommits", | ||
"releaseRules": [ | ||
{ "breaking": true, "release": "major" }, | ||
{ "revert": true, "release": "patch" }, | ||
{ "type": "build", "release": "patch" }, | ||
{ "type": "docs", "release": "patch" }, | ||
{ "type": "feat", "release": "minor" }, | ||
{ "type": "fix", "release": "patch" }, | ||
{ "type": "perf", "release": "patch" }, | ||
{ "type": "refactor", "release": "patch" }, | ||
{ "type": "chore", "release": "patch" } | ||
] | ||
} | ||
], | ||
[ | ||
"@semantic-release/release-notes-generator", | ||
{ | ||
"preset": "conventionalcommits", | ||
"presetConfig": { | ||
"types": [ | ||
{ "type": "build", "section": "Build", "hidden": false }, | ||
{ "type": "chore", "section": "Chores", "hidden": false }, | ||
{ "type": "ci", "section": "CI/CD", "hidden": false }, | ||
{ "type": "docs", "section": "Docs", "hidden": false }, | ||
{ "type": "feat", "section": "Features", "hidden": false }, | ||
{ "type": "fix", "section": "Bug Fixes", "hidden": false }, | ||
{ "type": "perf", "section": "Performance", "hidden": false }, | ||
{ "type": "refactor", "section": "Refactor", "hidden": false }, | ||
{ "type": "style", "section": "Code Style", "hidden": false }, | ||
{ "type": "test", "section": "Tests", "hidden": false } | ||
] | ||
} | ||
} | ||
], | ||
"@semantic-release/github" | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
ARG OSTYPE=linux-gnu | ||
ARG ARCHITECTURE=x86_64 | ||
ARG DOCKER_REGISTRY=ghcr.io | ||
ARG DOCKER_IMAGE_NAME | ||
|
||
# List out all image permutations to trick dependabot | ||
FROM --platform=linux/amd64 kong/kong-build-tools:apk-1.8.1 as x86_64-linux-musl | ||
FROM --platform=linux/amd64 kong/kong-build-tools:rpm-1.8.1 as x86_64-linux-gnu | ||
FROM --platform=linux/arm64 kong/kong-build-tools:apk-1.8.1 as aarch64-linux-musl | ||
FROM --platform=linux/arm64 kong/kong-build-tools:rpm-1.8.1 as aarch64-linux-gnu | ||
|
||
|
||
# Run the build script | ||
FROM $ARCHITECTURE-$OSTYPE as build | ||
|
||
COPY . /src | ||
RUN /src/build.sh && /src/test.sh | ||
|
||
|
||
# Copy the build result to scratch so we can export the result | ||
FROM scratch as package | ||
|
||
COPY --from=build /tmp/build / |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
ARCHITECTURE ?= x86_64 | ||
OSTYPE ?= linux-gnu | ||
DOCKER_TARGET ?= build | ||
DOCKER_REGISTRY ?= ghcr.io | ||
DOCKER_IMAGE_NAME ?= template-github-release | ||
DOCKER_IMAGE_TAG ?= $(DOCKER_TARGET)-$(ARCHITECTURE)-$(OSTYPE) | ||
DOCKER_NAME ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) | ||
DOCKER_RESULT ?= --load | ||
|
||
clean: | ||
rm -rf package | ||
docker rmi $(DOCKER_NAME) | ||
|
||
docker: | ||
docker buildx build \ | ||
--build-arg DOCKER_REGISTRY=$(DOCKER_REGISTRY) \ | ||
--build-arg DOCKER_IMAGE_NAME=$(DOCKER_IMAGE_NAME) \ | ||
--build-arg DOCKER_IMAGE_TAG=$(DOCKER_IMAGE_TAG) \ | ||
--build-arg ARCHITECTURE=$(ARCHITECTURE) \ | ||
--build-arg OSTYPE=$(OSTYPE) \ | ||
--target=$(DOCKER_TARGET) \ | ||
-t $(DOCKER_NAME) \ | ||
$(DOCKER_RESULT) . | ||
|
||
build/docker: | ||
docker inspect --format='{{.Config.Image}}' $(DOCKER_NAME) || \ | ||
$(MAKE) DOCKER_TARGET=build docker | ||
|
||
build/package: build/docker | ||
$(MAKE) DOCKER_TARGET=package DOCKER_RESULT="-o package" docker |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
if [ -n "${DEBUG:-}" ]; then | ||
set -x | ||
fi | ||
|
||
function main() { | ||
rm -rf /tmp/build/* && uname -a >> /tmp/build/out | ||
} | ||
|
||
main |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
if [ -n "${DEBUG:-}" ]; then | ||
set -x | ||
fi | ||
|
||
function test() { | ||
ls -lah /tmp/build/out | ||
} | ||
|
||
test |