Skip to content

Commit

Permalink
Merge pull request #2 from mook-as/ci/release-automation
Browse files Browse the repository at this point in the history
CI: Add workflow to create release on tagging
  • Loading branch information
jandubois authored Jun 17, 2024
2 parents 02b1287 + 430a323 commit 22b4029
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/package.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM alpine:latest AS builder
ARG ALPINE_VERSION=latest
FROM alpine:${ALPINE_VERSION} AS builder

RUN apk add alpine-sdk ccache doas git
RUN adduser -D abuild-user
Expand All @@ -21,15 +22,19 @@ RUN abuild -r
WORKDIR /alpine/openresty
RUN abuild -r

ARG TARGETARCH
ARG RELEASE_VERSION
WORKDIR /home/abuild-user/packages/alpine/
RUN cp ~/.abuild/rd-openresty-*.pub .
RUN tar cvf /tmp/openresty.tar \
RUN tar cvf /tmp/openresty-${TARGETARCH}.tar \
*.pub \
$(uname -m)/rd-openresty-[0-9]*.apk \
$(uname -m)/rd-openresty-openssl111-[0-9]*.apk \
$(uname -m)/rd-openresty-pcre-[0-9]*.apk \
$(uname -m)/rd-openresty-zlib-[0-9]*.apk
RUN if [ -n "${RELEASE_VERSION}" ]; \
then mv /tmp/openresty-${TARGETARCH}.tar /tmp/openresty-${RELEASE_VERSION}-${TARGETARCH}.tar; \
fi

FROM scratch
ARG TARGETARCH
COPY --from=builder /tmp/openresty.tar /openresty-${TARGETARCH}.tar
COPY --from=builder /tmp/openresty*.tar /
26 changes: 23 additions & 3 deletions .github/workflows/package.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
name: Package OpenResty
on:
workflow_dispatch: {}
workflow_dispatch:
inputs:
alpine-version:
description: Alpine Linux release version to build for
default: '3.20'
required: false
type: string
workflow_call:
inputs:
alpine-version:
description: Alpine Linux release version to build for
default: '3.20'
required: false
type: string
release-version:
description: Rancher Desktop OpenResty release tag
required: false
type: string
permissions: {}
jobs:
package:
Expand All @@ -22,9 +39,12 @@ jobs:
docker buildx build
--platform=linux/${{ matrix.arch }}
--output=type=local,dest=.
--file=.github/workflows/package.Dockerfile .
--file=.github/workflows/package.Dockerfile
--build-arg=RELEASE_VERSION=${{ inputs.release-version }}
--build-arg=ALPINE_VERSION=${{ inputs.alpine-version }}
.
- uses: actions/upload-artifact@v4
with:
name: openresty-${{ matrix.arch }}.tar
path: openresty-${{ matrix.arch }}.tar
path: openresty-*.tar
if-no-files-found: error
26 changes: 26 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Release OpenResty
on: { push: { tags: [ '*' ] } }
permissions: {}
jobs:
package:
uses: ./.github/workflows/package.yaml
with:
release-version: ${{ github.ref_name }}
release:
needs: package
runs-on: ubuntu-latest
permissions: { contents: write }
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.ref_name }}
run: >-
gh release create
"$ref"
openresty-*.tar/*.tar
--draft
--title "${ref#test-}"
--repo "${{ github.repository }}"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
*.dsc
*.build
*.buildinfo
*.changes
*.changes

/openresty-*.tar

0 comments on commit 22b4029

Please sign in to comment.