From 4df07ddb6e64edf55b665bccb27583897b937cbf Mon Sep 17 00:00:00 2001 From: Avi Deitcher Date: Mon, 11 Mar 2024 10:07:43 +0200 Subject: [PATCH] add support for pkg release tags Signed-off-by: Avi Deitcher --- .github/workflows/package_release.yml | 65 +++++++++++++++++++++++++++ docs/packages.md | 13 ++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/package_release.yml diff --git a/.github/workflows/package_release.yml b/.github/workflows/package_release.yml new file mode 100644 index 000000000..f2472b076 --- /dev/null +++ b/.github/workflows/package_release.yml @@ -0,0 +1,65 @@ +name: Release a tag + +on: + create: + tags: + - pkg-v* + +jobs: + build: + name: Release packages + runs-on: macos-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + - name: Ensure bin/ directory + run: mkdir -p bin + - name: Download linuxkit + uses: actions/github-script@v3.1.0 + with: + script: | + var artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id }}, + }); + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "${{ env.linuxkit_file }}" + })[0]; + var download = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/bin/${{ env.linuxkit_file }}.zip', Buffer.from(download.data)); + - name: unzip linuxkit + run: cd bin && unzip ${{ env.linuxkit_file }}.zip + - name: Symlink Linuxkit + run: | + chmod ugo+x bin/${{ env.linuxkit_file }} + sudo ln -s $(pwd)/bin/${{ env.linuxkit_file }} /usr/local/bin/linuxkit + /usr/local/bin/linuxkit version + - name: Restore Package Cache + uses: actions/cache@v3 + with: + path: ~/.linuxkit/cache/ + key: ${{ runner.os }}-linuxkit-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-linuxkit- + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Publish Packages as Release + # this should only push changed ones: + # - unchanged: already in the registry + # - changed: already built and cached, so only will push + # Skip s390x as emulation is unreliable + run: | + RELEASE_TAG=${GITHUB_REF#refs/tags/pkg-} + echo "RELEASE_TAG=${RELEASE_TAG}" + [ -n "${RELEASE_TAG}" ] || { echo "Not a tag"; exit 1; } + make OPTIONS="--skip-platforms linux/s390x" -C pkg push PUSHOPTIONS="--nobuild --release ${RELEASE_TAG}" diff --git a/docs/packages.md b/docs/packages.md index b2f01f802..aa8f55d0d 100644 --- a/docs/packages.md +++ b/docs/packages.md @@ -378,3 +378,16 @@ ARG all_proxy LinuxKit does not judge between lower-cased or upper-cased variants of these options, e.g. `http_proxy` vs `HTTP_PROXY`, as `docker build` does not either. It just passes them through "as-is". + +## Releases + +Normally, whenever a package is updated, CI will build and push the package to Docker Hub by calling `linuxkit pkg push`. +This automatically creates a tag based on the git tree hash of the package's directory. +For example, the package in `./pkg/init` is tagged as `linuxkit/init:45a1ad5919f0b6acf0f0cf730e9434abfae11fe6`. + +In addition, you can release semver tags for packages by adding a tag to the git repository that begins with `pkg-` and is +followed by a valid semver tag. For example, `pkg-v1.0.0`. This will cause CI to build and push the package to Docker Hub +with the tag `v1.0.0`. + +Pure semver tags, like `v1.0.0`, are not used for package releases. They are used for the linuxkit project itself and to +publish releases of the `linuxkit` binary.