-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from bodo-run/better-release-process
feat: implement tag-based release workflow
- Loading branch information
Showing
10 changed files
with
437 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
permissions: | ||
contents: write | ||
packages: write | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
include: | ||
- target: x86_64-apple-darwin | ||
os: macos-latest | ||
- target: aarch64-apple-darwin | ||
os: macos-latest | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
- target: aarch64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
- target: x86_64-pc-windows-msvc | ||
os: windows-latest | ||
- target: x86_64-pc-windows-gnu | ||
os: windows-latest | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Clean existing tags | ||
run: rm -rf .git/refs/tags/ | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.target }} | ||
|
||
- name: Install cross-compilation tools (Linux) | ||
if: runner.os == 'Linux' && contains(matrix.target, 'aarch64') | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gcc-aarch64-linux-gnu | ||
- name: Build | ||
run: | | ||
cargo build --release --target ${{ matrix.target }} | ||
mkdir -p "yek-${{ matrix.target }}" | ||
if [[ "${{ matrix.target }}" == *"windows"* ]]; then | ||
cp "target/${{ matrix.target }}/release/yek.exe" "yek-${{ matrix.target }}/" | ||
7z a "yek-${{ matrix.target }}.tar" "yek-${{ matrix.target }}" | ||
7z a "yek-${{ matrix.target }}.tar.gz" "yek-${{ matrix.target }}.tar" | ||
rm "yek-${{ matrix.target }}.tar" | ||
else | ||
cp "target/${{ matrix.target }}/release/yek" "yek-${{ matrix.target }}/" | ||
tar -czf "yek-${{ matrix.target }}.tar.gz" "yek-${{ matrix.target }}" | ||
fi | ||
shell: bash | ||
|
||
- name: Compute SHA256 | ||
id: sha | ||
run: | | ||
if [[ "${{ runner.os }}" == "Windows" ]]; then | ||
echo "sha256=$(certutil -hashfile yek-${{ matrix.target }}.tar.gz SHA256 | grep -v 'hash' | tr -d ' \r\n')" >> $GITHUB_OUTPUT | ||
else | ||
echo "sha256=$(shasum -a 256 yek-${{ matrix.target }}.tar.gz | awk '{print $1}')" >> $GITHUB_OUTPUT | ||
fi | ||
shell: bash | ||
|
||
- name: Create SHA file | ||
run: echo "${{ steps.sha.outputs.sha256 }}" > sha-${{ matrix.target }}.txt | ||
shell: bash | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: yek-${{ matrix.target }} | ||
path: yek-${{ matrix.target }}.tar.gz | ||
|
||
- name: Upload SHA | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: sha-${{ matrix.target }} | ||
path: sha-${{ matrix.target }}.txt | ||
|
||
release: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clean existing tags | ||
run: rm -rf .git/refs/tags/ | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Download artifacts | ||
uses: actions/download-artifact@v3 | ||
|
||
- name: Move artifacts to root | ||
run: | | ||
mv */yek-*.tar.gz ./ | ||
- name: Update Formula | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Get version from tag | ||
VERSION=${GITHUB_REF#refs/tags/v} | ||
# Update version in Formula | ||
sed -i "s/^ version \".*\"/ version \"${VERSION}\"/" Formula/yek.rb | ||
# Update each SHA256 | ||
for sha_file in sha-*/sha-*.txt; do | ||
target=$(echo $sha_file | cut -d/ -f1 | sed 's/sha-//') | ||
sha=$(cat $sha_file) | ||
sed -i "/url \".*yek-${target}.tar.gz\"/{n;s/sha256 \".*\"/sha256 \"${sha}\"/;}" Formula/yek.rb | ||
done | ||
# Configure git with token-based auth | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | ||
# Commit and push changes | ||
git add Formula/yek.rb | ||
git commit -m 'chore: update formula for release ${VERSION}' | ||
git push origin HEAD:main | ||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: yek-*.tar.gz | ||
generate_release_notes: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Cleanup tags | ||
run: | | ||
git fetch --prune --prune-tags | ||
git tag -l | xargs -r git tag -d | ||
git fetch --tags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
target/ | ||
*.log | ||
*.tmp | ||
*.tar.gz | ||
.DS_Store | ||
yek.toml | ||
repo-serialized/ | ||
dist/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "yek" | ||
version = "0.7.0" | ||
version = "0.7.4" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.