From 430a3237f1dcf340ff8785900ac6116d3fbd0852 Mon Sep 17 00:00:00 2001 From: Mark Yen Date: Thu, 13 Jun 2024 17:45:02 -0700 Subject: [PATCH] CI: Add workflow to create release on tagging The workflow matches some of our other repos: 1. The user pushes a tag to the repository. 2. Automation creates a draft release, populated with binaries. 3. The user publishes the release after testing. Signed-off-by: Mark Yen --- .github/workflows/package.Dockerfile | 13 +++++++++---- .github/workflows/package.yaml | 26 +++++++++++++++++++++++--- .github/workflows/release.yaml | 26 ++++++++++++++++++++++++++ .gitignore | 4 +++- 4 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/package.Dockerfile b/.github/workflows/package.Dockerfile index 8b2c564ef..14249c2c6 100644 --- a/.github/workflows/package.Dockerfile +++ b/.github/workflows/package.Dockerfile @@ -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 @@ -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 / diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml index 3cc4b22c8..2d6388378 100644 --- a/.github/workflows/package.yaml +++ b/.github/workflows/package.yaml @@ -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: @@ -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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 000000000..fc6ee529b --- /dev/null +++ b/.github/workflows/release.yaml @@ -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 }}" diff --git a/.gitignore b/.gitignore index 5d06813f6..616e82afc 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ *.dsc *.build *.buildinfo -*.changes \ No newline at end of file +*.changes + +/openresty-*.tar