Skip to content

Commit

Permalink
Rework the release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nickelc committed Jan 15, 2024
1 parent 464f25f commit 11be28f
Showing 1 changed file with 44 additions and 22 deletions.
66 changes: 44 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,34 +42,56 @@ jobs:
sudo apt-get install -y --no-install-recommends musl-tools
- name: Build
run: cargo build --release --target ${{ matrix.target }}

- name: Package
id: package
shell: bash
run: |
version=${GITHUB_REF#refs/tags/}
staging="modiom-$version-${{ matrix.target }}"
mkdir -p "$staging"
cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$staging/"
cargo build --release --target "${{ matrix.target }}"
if [ "${{ runner.os }}" = "Windows" ]; then
cp "target/${{ matrix.target }}/release/modiom.exe" "$staging/"
7z a "$staging.zip" "$staging"
echo "ASSET=$staging.zip" >> $GITHUB_OUTPUT
bin="target/${{ matrix.target }}/release/modiom.exe"
else
cp "target/${{ matrix.target }}/release/modiom" "$staging/"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_OUTPUT
bin="target/${{ matrix.target }}/release/modiom"
fi
echo "BIN=$bin" >>"$GITHUB_ENV"
- name: Determine archive name
shell: bash
run: |
version="$GITHUB_REF_NAME"
echo "ARCHIVE=modiom-$version-${{ matrix.target }}" >>"$GITHUB_ENV"
- name: Upload
uses: actions/upload-release-asset@v1.0.1
- name: Creating directory for archive
shell: bash
run: |
mkdir -p "$ARCHIVE"
cp "$BIN" "$ARCHIVE"/
cp {README.md,LICENSE-APACHE,LICENSE-MIT} "$ARCHIVE/"
- name: Build archive (Windows)
shell: bash
if: runner.os == 'Windows'
run: |
7z a "$ARCHIVE.zip" "$ARCHIVE"
certutil -hashfile "$ARCHIVE.zip" SHA256 >"$ARCHIVE.zip.sha256"
echo "ASSET=$ARCHIVE.zip" >>"$GITHUB_ENV"
echo "ASSET_SUM=$ARCHIVE.zip.sha256" >>"$GITHUB_ENV"
- name: Build archive (Unix)
shell: bash
if: runner.os != 'Windows'
run: |
tar czf "$ARCHIVE.tar.gz" "$ARCHIVE"
shasum -a 256 "$ARCHIVE.tar.gz" >"$ARCHIVE.tar.gz.sha256"
echo "ASSET=$ARCHIVE.tar.gz" >>"$GITHUB_ENV"
echo "ASSET_SUM=$ARCHIVE.tar.gz.sha256" >>"$GITHUB_ENV"
- name: Upload release archive
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_name: ${{ steps.package.outputs.ASSET }}
asset_path: ${{ steps.package.outputs.ASSET }}
asset_content_type: application/octet-stream
shell: bash
run:
echo "$ASSET"
echo "$ASSET_SUM"
file "$ASSET"
file "$ASSET_SUM"

gh release upload "${{ github.ref_name }}" "$ASSET" "$ASSET_SUM"

0 comments on commit 11be28f

Please sign in to comment.