build #121
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: build | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 20 * * *' | |
jobs: | |
check-binaries: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
app: [compose] | |
repo: ['docker/compose'] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/setup-buildx-action@v3 | |
- name: Get Version | |
run: | | |
APP_VERSION=$(curl -s "https://api.github.com/repos/${{ matrix.repo }}/releases/latest" | jq -r .tag_name) | |
GO_VERSION=$(curl -sSL https://github.com/${{ matrix.repo }}/raw/${APP_VERSION}/Dockerfile | grep '^ARG GO_VERSION=' | awk -F "=" '{print $2}') | |
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV | |
sed -i "s@ARG GO_VERSION=.*@ARG GO_VERSION=${GO_VERSION}@g" Dockerfile | |
sed -i "s@ARG COMPOSE_VERSION=.*@ARG COMPOSE_VERSION=${APP_VERSION}@g" Dockerfile | |
echo "" | |
echo "========== Build Args ==========" | |
echo "GO_VERSION=${GO_VERSION}" | |
echo "COMPOSE_VERSION=${APP_VERSION}" | |
- name: Check Release | |
id: check-release | |
run: | | |
gh release view ${{ env.APP_VERSION }} -R ${{ github.repository }} >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Tag | |
if : steps.check-release.outputs.create == '1' | |
run: | | |
git config --global user.name "${GITHUB_ACTOR}" | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git add . | |
git commit -m "Release ${{ env.APP_VERSION }}" || true | |
git tag ${{ env.APP_VERSION }} | |
git push origin ${{ env.APP_VERSION }} || true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create Release | |
if : steps.check-release.outputs.create == '1' | |
run: | | |
gh release create ${{ env.APP_VERSION }} -R ${{ github.repository }} --title ${{ env.APP_VERSION }} --notes "**Full Changelog**: [${{ env.APP_VERSION }}](https://github.com/docker/buildx/releases/tag/${{ env.APP_VERSION }})" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build-binaries: | |
runs-on: ubuntu-latest | |
needs: check-binaries | |
strategy: | |
matrix: | |
app: [compose] | |
repo: ['docker/compose'] | |
steps: | |
- name: Get Version | |
run: | | |
APP_VERSION=$(curl -s "https://api.github.com/repos/${{ matrix.repo }}/releases/latest" | jq -r .tag_name) | |
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.APP_VERSION }} | |
- uses: docker/setup-buildx-action@v3 | |
- name: Check Release | |
id: create-binaries | |
run: | | |
gh release view ${{ env.APP_VERSION }} -R ${{ github.repository }} | grep ${{ matrix.app }}-.* >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup QEMU | |
if : steps.create-binaries.outputs.create == '1' | |
run: docker run --rm --privileged ghcr.io/loong64/qemu-user-static --reset -p yes | |
- name: Build Binaries | |
if : steps.create-binaries.outputs.create == '1' | |
run: | | |
docker buildx build --platform linux/loong64 -t ${{ matrix.app }}-static-loong64:${{ env.APP_VERSION }} . --load | |
- name: Upgrade Release | |
if : steps.create-binaries.outputs.create == '1' | |
run: | | |
docker run --rm -v $(pwd)/dist:/dist ${{ matrix.app }}-static-loong64:${{ env.APP_VERSION }} | |
ls -al dist | |
gh release upload ${{ env.APP_VERSION }} -R ${{ github.repository }} dist/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |