-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (131 loc) · 4.93 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# referred from: https://github.com/PyO3/maturin/blob/main/.github/workflows/release.yml
name: Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
create_release :
if: startsWith(github.ref, 'refs/tags/')
name: release ${{ matrix.target }}
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Update CHANGELOG
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ github.ref_name }}
- name: Create Release
uses: ncipollo/[email protected]
with:
allowUpdates: true
draft: false
makeLatest: true
name: ${{ github.ref_name }}
body: ${{ steps.changelog.outputs.changes }}
token: ${{ github.token }}
release:
name: release
needs: create_release
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-gnu
os: windows-latest
ext: .exe
archive: zip
- target: x86_64-pc-windows-msvc
os: windows-latest
ext: .exe
archive: zip
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
archive: tar.gz
steps:
- name: Install dependencies
if: ${{ contains(matrix.target, 'musl') && startsWith(matrix.os, 'ubuntu-latest') }}
run: sudo apt-get update && sudo apt-get install -y musl-tools llvm clang
- name: Checkout
uses: actions/checkout@v4
- name: Cargo build
run: |
rustup toolchain install nightly --profile minimal -t ${{ matrix.target }}
cargo +nightly build --release --target ${{ matrix.target }}
env:
RUSTFLAGS: -C strip=symbols
- name: Packaging Archive .zip
if: ${{ startsWith(matrix.os, 'windows-latest') }}
run: |
Get-ChildItem -Path .\README.md,.\config.example.toml,.\target\${{ matrix.target }}\release\ -Filter *.exe |
Compress-Archive -DestinationPath jsdelivr_proxy-${{ matrix.target }}.zip -Force
- name: Packaging Archive .tar.gz
if: ${{ !startsWith(matrix.os, 'windows-latest') }}
run: |
mkdir -p ./tmp && cp ./README.md ./config.example.toml ./target/${{ matrix.target }}/release/jsdelivr_proxy ./tmp && cd ./tmp && tar -czvf ../jsdelivr_proxy-${{ matrix.target }}.tar.gz . && cd .. && rm -rf ./tmp
- name: Upload asset
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ github.token }}
tag: ${{ github.ref }}
file: jsdelivr_proxy-${{ matrix.target }}.${{ matrix.archive }}
asset_name: jsdelivr_proxy-${{ matrix.target }}.${{ matrix.archive }}
docker-release:
name: docker release
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
hitokoto/jsdelivr-proxy
tags: |
type=ref,event=tag
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
labels: |
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/hitokoto-osc/jsdelivr_proxy/master/README.md
io.artifacthub.package.logo-url=https://cdn.a632079.me/assets/images/hitokoto-logo-512x512.png
io.artifacthub.package.maintainers=[{"name":"a632079","email":"[email protected]"}]
io.artifacthub.package.license=Apache-2.0
org.opencontainers.image.description=jsdelivr proxy
org.opencontainers.image.created=${{ github.event.release.created_at }}
org.opencontainers.image.name=jsdelivr-proxy
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version={{version}}
org.opencontainers.image.source=https://github.com/hitokoto-osc/jsdelivr_proxy/
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}