name: Release on: release: types: [created] permissions: contents: write packages: write jobs: build: runs-on: ubuntu-latest strategy: matrix: goos: [linux, windows, darwin] goarch: [amd64, arm64] exclude: - goos: darwin goarch: amd64 steps: - uses: actions/checkout@v4 - name: Set up Go uses: actions/setup-go@v5 with: go-version: '1.22' - name: Build binary env: GOOS: ${{ matrix.goos }} GOARCH: ${{ matrix.goarch }} run: | BINARY_NAME="object-holder" if [ "$GOOS" = "windows" ]; then BINARY_NAME="${BINARY_NAME}.exe" fi go build -v -o "${BINARY_NAME}" ./... - name: Create archive run: | BINARY_NAME="object-holder" if [ "${{ matrix.goos }}" = "windows" ]; then BINARY_NAME="${BINARY_NAME}.exe" fi ARCHIVE_NAME="object-holder-${{ github.ref_name }}-${{ matrix.goos }}-${{ matrix.goarch }}" # Create directory structure mkdir -p "${ARCHIVE_NAME}" cp "${BINARY_NAME}" README.md LICENSE "${ARCHIVE_NAME}/" if [ "${{ matrix.goos }}" = "windows" ]; then zip -r "${ARCHIVE_NAME}.zip" "${ARCHIVE_NAME}" echo "ASSET_PATH=${ARCHIVE_NAME}.zip" >> $GITHUB_ENV else tar -czf "${ARCHIVE_NAME}.tar.gz" "${ARCHIVE_NAME}" echo "ASSET_PATH=${ARCHIVE_NAME}.tar.gz" >> $GITHUB_ENV fi - name: Upload release asset uses: softprops/action-gh-release@v2 with: files: ${{ env.ASSET_PATH }} docker: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to ghcr uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ghcr.io/${{ github.repository }} tags: | type=ref,event=tag type=raw,value=latest - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}