ci: bug #8
Workflow file for this run
This file contains hidden or 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: Docker Build and Push | |
| on: | |
| push: | |
| branches: [main, master] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main, master] | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| if: github.event_name != 'pull_request' | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| else | |
| VERSION=1.3.2 | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: | | |
| sctg/libtermcap:${{ steps.version.outputs.version }} | |
| sctg/libtermcap:musl-${{ steps.version.outputs.version }} | |
| sctg/libtermcap:musl | |
| sctg/libtermcap:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Docker Hub Description | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: peter-evans/dockerhub-description@v5 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| repository: sctg/libtermcap | |
| readme-filepath: ./DOCKER.md | |
| release: | |
| needs: docker | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build aarch64 release package | |
| run: | | |
| mkdir -p build-aarch64/libtermcap-${{ steps.version.outputs.version }}-aarch64/lib | |
| mkdir -p build-aarch64/libtermcap-${{ steps.version.outputs.version }}-aarch64/include | |
| mkdir -p build-aarch64/libtermcap-${{ steps.version.outputs.version }}-aarch64/lib/pkgconfig | |
| docker run --platform linux/arm64 --rm \ | |
| -v $(pwd)/build-aarch64/libtermcap-${{ steps.version.outputs.version }}-aarch64:/extract \ | |
| sctg/libtermcap:musl-${{ steps.version.outputs.version }} \ | |
| sh -c "cp /usr/local/lib/libtermcap.a /extract/lib/ && cp /usr/local/include/termcap.h /extract/include/" | |
| cp termcap.pc build-aarch64/libtermcap-${{ steps.version.outputs.version }}-aarch64/lib/pkgconfig/ | |
| cd build-aarch64 | |
| tar -czf libtermcap-${{ steps.version.outputs.version }}-aarch64.tar.gz \ | |
| libtermcap-${{ steps.version.outputs.version }}-aarch64/ | |
| cd .. | |
| - name: Build x86_64 release package | |
| run: | | |
| mkdir -p build-x86_64/libtermcap-${{ steps.version.outputs.version }}-x86_64/lib | |
| mkdir -p build-x86_64/libtermcap-${{ steps.version.outputs.version }}-x86_64/include | |
| mkdir -p build-x86_64/libtermcap-${{ steps.version.outputs.version }}-x86_64/lib/pkgconfig | |
| docker run --platform linux/amd64 --rm \ | |
| -v $(pwd)/build-x86_64/libtermcap-${{ steps.version.outputs.version }}-x86_64:/extract \ | |
| sctg/libtermcap:musl-${{ steps.version.outputs.version }} \ | |
| sh -c "cp /usr/local/lib/libtermcap.a /extract/lib/ && cp /usr/local/include/termcap.h /extract/include/" | |
| cp termcap.pc build-x86_64/libtermcap-${{ steps.version.outputs.version }}-x86_64/lib/pkgconfig/ | |
| cd build-x86_64 | |
| tar -czf libtermcap-${{ steps.version.outputs.version }}-x86_64.tar.gz \ | |
| libtermcap-${{ steps.version.outputs.version }}-x86_64/ | |
| cd .. | |
| - name: Create Release | |
| run: | | |
| gh release upload v${{ steps.version.outputs.version }} \ | |
| build-aarch64/libtermcap-${{ steps.version.outputs.version }}-aarch64.tar.gz \ | |
| build-x86_64/libtermcap-${{ steps.version.outputs.version }}-x86_64.tar.gz | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |