diff options
author | Jakob Borg <jakob@kastelo.net> | 2023-06-14 09:23:52 +0200 |
---|---|---|
committer | Jakob Borg <jakob@kastelo.net> | 2023-06-14 09:28:04 +0200 |
commit | 439fa6c84861cfb22c8faec962302c1f332f705d (patch) | |
tree | 46f40673a32852b69d4b503cbbf5e55c8a0d7cb2 /.github | |
parent | 6b475bdb78eb671866419ff84a4cda6285c90244 (diff) | |
download | syncthing-439fa6c84861cfb22c8faec962302c1f332f705d.tar.gz syncthing-439fa6c84861cfb22c8faec962302c1f332f705d.zip |
build: Multi arch Docker images with GitHub actions (ref #8834)
This builds and publishes our Docker images from GitHub.
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/build-syncthing.yaml | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/.github/workflows/build-syncthing.yaml b/.github/workflows/build-syncthing.yaml index 20b3f83fd..27809e551 100644 --- a/.github/workflows/build-syncthing.yaml +++ b/.github/workflows/build-syncthing.yaml @@ -624,3 +624,70 @@ jobs: RCLONE_CONFIG_SPACES_ACL: public-read with: args: sync packages spaces:syncthing/release/${{ env.VERSION }} + + docker-syncthing: + name: Build and push Docker images + runs-on: ubuntu-latest + if: github.event_name == 'push' && (github.ref == 'refs/heads/release' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release-')) + environment: docker + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v4 + with: + go-version: ${{ env.GO_VERSION }} + + - uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-docker-${{ hashFiles('**/go.sum') }} + + - name: Build binaries + run: | + for arch in arm64 amd64; do + go run build.go -goos linux -goarch "$arch" build syncthing + mv syncthing syncthing-linux-"$arch" + done + env: + CGO_ENABLED: "0" + BUILD_USER: docker + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Set version tags + run: | + version=$(go run build.go version) + version=${version#v} + if [[ $version == @([0-9]|[0-9][0-9]).@([0-9]|[0-9][0-9]).@([0-9]|[0-9][0-9]) ]] ; then + echo Release version, pushing to :latest and version tags + major=${version%.*.*} + minor=${version%.*} + tags=syncthing/syncthing:$version,syncthing/syncthing:$major,syncthing/syncthing:$minor,syncthing/syncthing:latest + elif [[ $version == *-rc.@([0-9]|[0-9][0-9]) ]] ; then + echo Release candidate, pushing to :rc + tags=syncthing/syncthing:rc + else + echo Development version, pushing to :edge + tags=syncthing/syncthing:edge + fi + echo "DOCKER_TAGS=$tags" >> $GITHUB_ENV + + - name: Build and push syncthing + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ env.DOCKER_TAGS }} |