-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1473f9
commit a5f3e80
Showing
2 changed files
with
116 additions
and
0 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,35 @@ | ||
#!/usr/bin/env bash | ||
|
||
# from: https://github.com/EmbarkStudios/cargo-about/blob/7b08ebebf6b729a8e6e5227e9117617ee2b8003e/.github/scripts/package.sh | ||
set -eu | ||
|
||
# When run in a container, the ownership will be messed up, so mark the | ||
# checkout dir as safe regardless of our env | ||
git config --global --add safe.directory "$GITHUB_WORKSPACE" | ||
|
||
# Normally we'll only do this on tags, but add --always to fallback to the revision | ||
# if we're iterating or the like | ||
tag=$(git describe --tags --abbrev=0 --always) | ||
release_name="$NAME-$tag-$TARGET" | ||
release_tar="${release_name}.tar.gz" | ||
mkdir "$release_name" | ||
|
||
if [[ "$TARGET" =~ windows ]]; then | ||
bin="$NAME.exe" | ||
else | ||
bin="$NAME" | ||
fi | ||
|
||
cp "target/$TARGET/release/$bin" "$release_name/" | ||
cp README.md LICENSE "$release_name/" | ||
tar czf "$release_tar" "$release_name" | ||
|
||
rm -r "$release_name" | ||
|
||
# Windows environments in github actions don't have the gnu coreutils installed, | ||
# which includes the shasum exe, so we just use powershell instead | ||
if [[ "$TARGET" =~ windows ]]; then | ||
echo "(Get-FileHash \"${release_tar}\" -Algorithm SHA256).Hash | Out-File -Encoding ASCII -NoNewline \"${release_tar}.sha256\"" | pwsh -c - | ||
else | ||
echo -n "$(shasum -ba 256 "${release_tar}" | cut -d " " -f 1)" > "${release_tar}.sha256" | ||
fi |
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,81 @@ | ||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
name: Create release and publish binaries | ||
|
||
jobs: | ||
generate-changelog: | ||
name: Generate changelog | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Generate changelog | ||
id: changelog | ||
uses: requarks/changelog-action@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.ref_name }} | ||
|
||
- name: Upload changelog | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: changelog | ||
path: CHANGELOG.md | ||
|
||
- name: Commit CHANGELOG.md | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
branch: main | ||
commit_message: "chore(main): release ${{ github.ref_name }}" | ||
file_pattern: CHANGELOG.md | ||
|
||
build-and-package: | ||
name: Build and package binaries | ||
needs: generate-changelog | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: dtolnay/rust-toolchain@stable | ||
with: | ||
target: ${{ matrix.target }} | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build | ||
run: cargo build --release --target ${{ matrix.target }} | ||
|
||
- name: Package | ||
shell: bash | ||
env: | ||
NAME: gitrc-rs | ||
TARGET: ${{ matrix.target }} | ||
run: .github/scripts/package.sh | ||
|
||
- name: Get changelog | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: changelog | ||
|
||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
draft: false | ||
make_latest: true | ||
body_path: CHANGELOG.md | ||
files: "gitrc-rs*" |