-
-
Notifications
You must be signed in to change notification settings - Fork 5
118 lines (114 loc) · 4.06 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Release
on:
push:
branches:
- "main"
tags:
- "v*"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
# https://github.com/Mozilla-Actions/sccache-action#rust-code
# RUSTC_WRAPPER: "sccache"
# SCCACHE_GHA_ENABLED: "true"
jobs:
build:
if: "startsWith(github.ref, 'refs/tags/v') || !contains(github.event.head_commit.message, 'chore: release')"
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
command: _build
musl: false
- target: x86_64-unknown-linux-musl
command: _build
musl: true
- target: aarch64-unknown-linux-gnu
command: _zigbuild
musl: false
- target: aarch64-unknown-linux-musl
command: _zigbuild
musl: true
name: build ${{ matrix.target }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@nightly
- uses: taiki-e/install-action@just
# - uses: mozilla-actions/sccache-action@v0.0.3
- if: matrix.command == '_zigbuild'
uses: mlugg/setup-zig@v1
- if: matrix.musl == true
run: sudo apt update && sudo apt install -y musl-tools && sudo ln -s /bin/g++ /bin/musl-g++
- run: just ${{ matrix.command }} ${{ matrix.target }}
- uses: actions/upload-artifact@v4
with:
name: hatsu.${{ matrix.target }}
path: target/${{ matrix.target }}/release/hatsu
if-no-files-found: error
retention-days: 30
- if: startsWith(github.ref, 'refs/tags/v')
uses: TheDoctor0/zip-release@0.7.6
with:
type: tar
filename: hatsu.${{ matrix.target }}.tar
directory: target/${{ matrix.target }}/release/
path: hatsu
- if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
with:
draft: true
generate_release_notes: true
prerelease: ${{ contains(github.ref, '-') }}
files: target/${{ matrix.target }}/release/hatsu.${{ matrix.target }}.tar
docker:
name: docker buildx
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: hatsu.x86_64-unknown-linux-gnu
path: target_amd64
- uses: actions/download-artifact@v4
with:
name: hatsu.aarch64-unknown-linux-gnu
path: target_arm64
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
flavor: |
latest=false
labels: |
org.opencontainers.image.title=Hatsu
org.opencontainers.image.description=Self-hosted & Fully-automated ActivityPub Bridge for Static Sites.
# https://github.com/docker/metadata-action#major-version-zero
tags: |
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}}.{{minor}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=semver,pattern={{major}},enable=${{ startsWith(github.ref, 'refs/tags/v') && !startsWith(github.ref, 'refs/tags/v0.') }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
type=raw,value=beta,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
type=raw,value=nightly
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}