-
Notifications
You must be signed in to change notification settings - Fork 1
184 lines (171 loc) · 5.78 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-rc[0-9]+'
env:
CARGO_TERM_COLOR: always
jobs:
prepare-env:
name: Prepare environment
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.prepare-env.outputs.RELEASE_VERSION }}
steps:
- name: Get the release version from the tag
id: prepare-env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
build-release:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
needs: ['prepare-env']
name: build-release
runs-on: ${{ matrix.os }}
steps:
# checkout code
- uses: actions/checkout@v4
# install just
- uses: extractions/setup-just@v1
# cache
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/.crates.toml
~/.cargo/.crates2.json
key: ${{ runner.os }}-cargo-${{ matrix.target }}
# install rust
- run: rustup show && rustup target add ${{ matrix.target }}
# install dependencies
- run: just setup
# build (generates binaries)
- run: just build --locked --release --target=${{ matrix.target }}
- run: cargo test --locked manpage
# create archive
- name: Archive
shell: bash
run: |
staging="i3stat-${{ matrix.target }}"
mkdir "$staging"
cp -a doc "$staging"
files=(
"target/${{ matrix.target }}/release/i3stat"
"target/${{ matrix.target }}/release/i3stat-ipc"
"target/${{ matrix.target }}/release/i3stat-acpi"
"target/${{ matrix.target }}/release/i3stat-sensors"
"target/${{ matrix.target }}/release/i3stat-signals"
"README.md"
"sample_config.toml"
"sample_included_config.toml"
"LICENSE"
)
for file in ${files[@]}; do
cp $file "$staging"
done
zip -r "$staging.zip" "$staging"
# upload zip as an artifact (as a folder called `artifact`)
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: artifacts
path: i3stat-${{ matrix.target }}.zip
release-crates:
name: Publish crate
needs: ['build-release']
runs-on: ubuntu-latest
steps:
# checkout code
- uses: actions/checkout@v4
# install just
- uses: extractions/setup-just@v1
# install rust
- run: rustup show
# install dependencies
- run: just setup
# publish crate
- shell: bash
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish
release-aur:
name: Update AUR(i3stat)
needs: ['release-crates', 'prepare-env']
runs-on: ubuntu-latest
steps:
- uses: extractions/setup-just@v1
- name: Setup SSH
run: |
eval "$(ssh-agent -s)"
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV
ssh-add - <<< "${{ secrets.AUR_SSH_KEY }}"
mkdir -p $HOME/.ssh/
echo "${{ vars.SSH_KNOWN_HOSTS }}" >> $HOME/.ssh/known_hosts
chmod 0600 $HOME/.ssh/*
- run: |
git clone ssh://[email protected]/i3stat.git aur && cd "$_" && git checkout master
sudo chown -R 1000:1000 "$PWD"
docker run \
--rm \
-v "$PWD:/pkg" \
--env "GIT_AUTHOR_NAME=acheronfail" \
--env "GIT_COMMITTER_NAME=acheronfail" \
--env "[email protected]" \
--env "[email protected]" \
acheronfail/makepkg just update ${{ needs.prepare-env.outputs.release_version }}
sudo chown -R $USER:$USER "$PWD"
git push
release-aur-bin:
name: Update AUR(i3stat-bin)
needs: ['release-github', 'prepare-env']
runs-on: ubuntu-latest
steps:
- uses: extractions/setup-just@v1
- name: Setup SSH
run: |
eval "$(ssh-agent -s)"
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV
ssh-add - <<< "${{ secrets.AUR_SSH_KEY }}"
mkdir -p $HOME/.ssh/
echo "${{ vars.SSH_KNOWN_HOSTS }}" >> $HOME/.ssh/known_hosts
chmod 0600 $HOME/.ssh/*
- run: |
git clone ssh://[email protected]/i3stat-bin.git aur && cd "$_" && git checkout master
sudo chown -R 1000:1000 "$PWD"
docker run \
--rm \
-v "$PWD:/pkg" \
--env "GIT_AUTHOR_NAME=acheronfail" \
--env "GIT_COMMITTER_NAME=acheronfail" \
--env "[email protected]" \
--env "[email protected]" \
acheronfail/makepkg just update ${{ needs.prepare-env.outputs.release_version }}
sudo chown -R $USER:$USER "$PWD"
git push
release-github:
name: GitHub Release
needs: ['build-release', 'prepare-env']
runs-on: ubuntu-latest
steps:
# downloads artifacts (this downloads the folder called `artifacts` defined in the `build-release` step)
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: .
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/i3stat-x86_64-unknown-linux-gnu.zip
tag_name: ${{ needs.prepare-env.outputs.release_version }}
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}