mirror of
https://github.com/dcarrillo/whatismyip.git
synced 2026-07-23 22:45:46 +00:00
feat: Create multiarch artifacts (#58)
This commit is contained in:
+92
-16
@@ -27,17 +27,26 @@ jobs:
|
||||
- name: ${{ matrix.make }}
|
||||
run: make ${{ matrix.make }}
|
||||
|
||||
deploy:
|
||||
build-binaries:
|
||||
runs-on: ubuntu-latest
|
||||
needs: tests
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||
strategy:
|
||||
matrix:
|
||||
goosarch: [linux-amd64]
|
||||
include:
|
||||
- goos: linux
|
||||
goarch: amd64
|
||||
- goos: linux
|
||||
goarch: arm64
|
||||
- goos: darwin
|
||||
goarch: amd64
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
- goos: windows
|
||||
goarch: amd64
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: install go
|
||||
uses: actions/setup-go@v6
|
||||
with:
|
||||
@@ -47,27 +56,94 @@ jobs:
|
||||
- name: Set env
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Sign in to dockerhub
|
||||
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
|
||||
|
||||
- name: Deploy image
|
||||
run: make docker-push VERSION=$RELEASE_VERSION
|
||||
|
||||
- name: Build
|
||||
run: make build VERSION=$RELEASE_VERSION
|
||||
run: make build VERSION="$RELEASE_VERSION" GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }}
|
||||
|
||||
- name: Prepare release
|
||||
- name: Package
|
||||
run: |
|
||||
BASE="whatismyip-$RELEASE_VERSION-${{ matrix.goos }}-${{ matrix.goarch }}"
|
||||
if [ "${{ matrix.goos }}" = "windows" ]; then
|
||||
cp whatismyip "${BASE}.exe"
|
||||
zip "${BASE}.zip" "${BASE}.exe" LICENSE README.md
|
||||
sha256sum "${BASE}.zip" > "${BASE}.zip.sha256"
|
||||
else
|
||||
tar zcvf "${BASE}.tar.gz" whatismyip LICENSE README.md
|
||||
sha256sum "${BASE}.tar.gz" > "${BASE}.tar.gz.sha256"
|
||||
fi
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: binary-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
path: |
|
||||
whatismyip-${{ env.RELEASE_VERSION }}-${{ matrix.goos }}-${{ matrix.goarch }}.*
|
||||
if-no-files-found: error
|
||||
|
||||
publish-docker:
|
||||
runs-on: ubuntu-latest
|
||||
needs: tests
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Set env
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: Sign in to Docker Hub
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
build-args: ARG_VERSION=${{ env.RELEASE_VERSION }}
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/whatismyip:${{ env.RELEASE_VERSION }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/whatismyip:latest
|
||||
push: true
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [build-binaries, publish-docker]
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set env
|
||||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
pattern: binary-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Generate changelog
|
||||
run: |
|
||||
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:%h - %s <%an>' --no-merges > changelog.txt
|
||||
tar zcvf whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz whatismyip LICENSE README.md
|
||||
sha256sum whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz > whatismyip-$RELEASE_VERSION-${{matrix.goosarch}}.tar.gz.sha256
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
body_path: changelog.txt
|
||||
files: |
|
||||
whatismyip-${{env.RELEASE_VERSION}}-${{matrix.goosarch}}.tar.gz
|
||||
whatismyip-${{env.RELEASE_VERSION}}-${{matrix.goosarch}}.tar.gz.sha256
|
||||
whatismyip-${{ env.RELEASE_VERSION }}-*.tar.gz
|
||||
whatismyip-${{ env.RELEASE_VERSION }}-*.tar.gz.sha256
|
||||
whatismyip-${{ env.RELEASE_VERSION }}-*.zip
|
||||
whatismyip-${{ env.RELEASE_VERSION }}-*.zip.sha256
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
Reference in New Issue
Block a user