cd·docker #65
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
name: cd·docker | |
on: | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
inputs: | |
tag: | |
required: true | |
concurrency: | |
group: docker/${{ github.event.release.tag_name || github.event.inputs.tag }} | |
cancel-in-progress: true | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build-and-push-image: | |
name: docker buildx pkgxdev/pkgx:${{ github.event.release.tag_name || github.event.inputs.tag }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: robinraju/[email protected] | |
with: | |
releaseId: ${{ github.event.release.id }} | |
tag: ${{ github.event.inputs.tag }} | |
fileName: pkgx-*.tar.xz | |
- name: is_latest? | |
id: latest | |
run: | | |
TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.tag }}" | |
LATEST_RELEASE=$(gh api repos/${{ github.repository }}/releases/latest --jq '.tag_name') | |
if [ "$TAG_NAME" == "$LATEST_RELEASE" ]; then | |
echo "value=true" >> "${GITHUB_OUTPUT}" | |
else | |
echo "value=false" >> "${GITHUB_OUTPUT}" | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Unpack Binaries | |
run: | | |
for filename in pkgx-*+*+*.tar.xz; do | |
tar xJf $filename | |
result="${filename#*+}" | |
result="${result%.tar.xz}" | |
mv pkgx $result | |
rm $filename | |
done | |
mkdir products | |
mv linux+x86-64 products/x86_64 | |
mv linux+aarch64 products/aarch64 | |
curl -o products/pkgm https://pkgxdev.github.io/pkgm/pkgm.ts | |
- uses: actions/checkout@v4 | |
with: | |
path: src | |
- name: log in to docker hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USER_NAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- uses: docker/metadata-action@v5 | |
id: meta | |
with: | |
images: pkgxdev/pkgx | |
flavor: | | |
latest=${{ steps.latest.outputs.value }} | |
tags: | | |
type=sha | |
type=semver,pattern=v{{version}},value=${{ github.event.release.tag_name || github.event.inputs.tag }} | |
type=semver,pattern=v{{major}}.{{minor}},value=${{ github.event.release.tag_name || github.event.inputs.tag }} | |
type=semver,pattern=v{{major}},value=${{ github.event.release.tag_name || github.event.inputs.tag }} | |
- uses: docker/setup-qemu-action@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- name: docker/buildx | |
run: | | |
for x in $(echo "${{ steps.meta.outputs.tags }}" | tr '\n' ' '); | |
do tags="$tags --tag $x"; | |
done | |
docker buildx build \ | |
--push \ | |
$tags \ | |
--platform linux/amd64,linux/arm64 \ | |
--file ./src/.github/Dockerfile \ | |
. |