Skip to content

Commit cb02f8b

Browse files
Update release.yml
1 parent 351868e commit cb02f8b

File tree

1 file changed

+35
-67
lines changed

1 file changed

+35
-67
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,93 @@
1-
name: Build and Release App
1+
name: Release
22

33
on:
4+
push:
5+
branches: [ main ]
46
workflow_dispatch:
57

68
permissions:
79
contents: write
10+
pull-requests: write
811

912
concurrency:
1013
group: release-${{ github.ref }}
1114
cancel-in-progress: true
1215

1316
jobs:
14-
version:
17+
release-please:
1518
runs-on: ubuntu-latest
1619
outputs:
17-
version: ${{ steps.v.outputs.version }}
20+
released: ${{ steps.release.outputs.release_created }}
21+
tag: ${{ steps.release.outputs.tag_name }}
1822
steps:
19-
- uses: actions/checkout@v4
20-
- id: v
21-
run: |
22-
V=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
23-
echo "version=$V" >> $GITHUB_OUTPUT
24-
25-
changelog:
26-
runs-on: ubuntu-latest
27-
steps:
28-
- uses: actions/checkout@v4
23+
- uses: googleapis/release-please-action@v4
24+
id: release
2925
with:
30-
fetch-depth: 0
31-
32-
- name: Install git-cliff
33-
run: |
34-
VERSION=$(gh release view --repo orhun/git-cliff --json tagName -q .tagName)
35-
curl -sL "https://github.com/orhun/git-cliff/releases/download/${VERSION}/git-cliff-${VERSION}-x86_64-unknown-linux-gnu.tar.gz" | tar -xz
36-
sudo mv git-cliff /usr/local/bin/
37-
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
40-
- name: Generate changelog
41-
run: git-cliff -o CHANGELOG.md
42-
43-
- uses: actions/upload-artifact@v4
44-
with:
45-
name: changelog
46-
path: CHANGELOG.md
26+
config-file: .github/release-please-config.json
4727

4828
build:
49-
needs: version
29+
needs: release-please
30+
if: needs.release-please.outputs.released == 'true'
5031
strategy:
5132
matrix:
5233
include:
5334
- os: ubuntu-latest
5435
target: x86_64-unknown-linux-gnu
5536
bin: pyelevate
56-
osname: linux
5737
ext: ""
58-
pack: tar
38+
archive: tar.gz
39+
5940
- os: windows-latest
6041
target: x86_64-pc-windows-msvc
6142
bin: pyelevate.exe
62-
osname: windows
6343
ext: ".exe"
64-
pack: zip
44+
archive: zip
45+
6546
- os: macos-latest
6647
target: aarch64-apple-darwin
6748
bin: pyelevate
68-
osname: macos-arm64
6949
ext: ""
70-
pack: tar
50+
archive: tar.gz
7151

7252
runs-on: ${{ matrix.os }}
7353

7454
steps:
7555
- uses: actions/checkout@v4
56+
7657
- uses: dtolnay/rust-toolchain@stable
58+
7759
- uses: Swatinem/rust-cache@v2
7860

7961
- run: rustup target add ${{ matrix.target }}
80-
- run: cargo build --release --target ${{ matrix.target }}
8162

82-
- name: Ensure zip exists
83-
if: matrix.os == 'windows-latest'
84-
run: choco install zip -y
63+
- run: cargo build --release --target ${{ matrix.target }}
8564

8665
- name: Package
8766
shell: bash
8867
run: |
89-
NAME=pyelevate-v${{ needs.version.outputs.version }}-${{ matrix.osname }}
90-
mkdir pkg
91-
cp target/${{ matrix.target }}/release/${{ matrix.bin }} pkg/pyelevate${{ matrix.ext }}
68+
VERSION=${{ needs.release-please.outputs.tag }}
69+
NAME=pyelevate-${VERSION}-${{ matrix.target }}
9270
93-
if [ "${{ matrix.pack }}" = "zip" ]; then
94-
cd pkg && zip -9 ../$NAME.zip *
71+
mkdir dist
72+
cp target/${{ matrix.target }}/release/${{ matrix.bin }} dist/
73+
74+
cd dist
75+
76+
if [ "${{ matrix.archive }}" = "zip" ]; then
77+
powershell Compress-Archive -Path * -DestinationPath ../$NAME.zip
9578
else
96-
tar -C pkg -cJf $NAME.tar.xz .
79+
tar -czf ../$NAME.tar.gz *
9780
fi
9881
82+
cd ..
9983
sha256sum $NAME.* > $NAME.sha256
10084
101-
- uses: actions/upload-artifact@v4
85+
- uses: softprops/action-gh-release@v2
10286
with:
103-
name: ${{ matrix.osname }}
104-
path: |
87+
tag_name: ${{ needs.release-please.outputs.tag }}
88+
files: |
10589
*.zip
106-
*.tar.xz
90+
*.tar.gz
10791
*.sha256
108-
109-
release:
110-
needs: [version, build, changelog]
111-
runs-on: ubuntu-latest
112-
113-
steps:
114-
- uses: actions/download-artifact@v4
115-
with:
116-
path: artifacts
117-
118-
- uses: softprops/action-gh-release@v2
119-
with:
120-
tag_name: v${{ needs.version.outputs.version }}
121-
name: PyElevate v${{ needs.version.outputs.version }}
122-
body_path: artifacts/changelog/CHANGELOG.md
123-
files: artifacts/**/*
12492
env:
12593
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)