Fix release and release 0.2.1 (#10) #6
Workflow file for this run
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
name: "Release" | |
on: | |
push: | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+" | |
permissions: | |
contents: write | |
jobs: | |
create-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get the release version from the tag | |
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | |
- name: Check that tag version and cli Cargo.toml version match | |
run: | | |
if ! grep -q "version = \"$VERSION\"" ./Cargo.toml; then | |
echo "Tag version $VERSION does not match Cargo.toml version" >&2 | |
exit 1 | |
fi | |
- name: Create GitHub release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: gh release create $VERSION --draft --verify-tag --title $VERSION | |
outputs: | |
version: ${{ env.VERSION }} | |
build-release: | |
needs: | |
- create-release | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: x86_64-unknown-linux-gnu | |
os: ubuntu-latest | |
rust: stable | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install rust | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
- name: Build release | |
run: | | |
cargo build --release -p cli --verbose --target ${{ matrix.target }} | |
RELEASE_DIR="target/${{ matrix.target }}/release" | |
mv "${RELEASE_DIR}/cli" "${RELEASE_DIR}/runner" | |
echo "BIN=$RELEASE_DIR/runner" >> $GITHUB_ENV | |
- name: Set archive name | |
run: | | |
version="${{ needs.create-release.outputs.version }}" | |
echo "ARCHIVE=runner-$version-${{ matrix.target }}" >> $GITHUB_ENV | |
- name: Create archive directory | |
run: | | |
echo "Creating archive: $ARCHIVE" | |
mkdir -p "$ARCHIVE" | |
cp "$BIN" "$ARCHIVE"/ | |
cp LICENSE "$ARCHIVE"/ | |
ls -la "$ARCHIVE"/ | |
- name: Archive release | |
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 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
version="${{ needs.create-release.outputs.version }}" | |
gh release upload "$version" "$ASSET" "$ASSET_SUM" | |
docker-release: | |
needs: | |
- build-release | |
- create-release | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: "Prepare environment" | |
run: | | |
echo "IMAGE_TAG=${{ needs.create-release.outputs.version }}" >> $GITHUB_ENV | |
echo "IMAGE_NAME=bountyhuborg/runner" >> $GITHUB_ENV | |
echo "BUILD_PLATFORMS=linux/amd64" >> $GITHUB_ENV | |
- name: Build image | |
env: | |
DOCKER_BUILDKIT: 1 | |
run: | | |
docker buildx build --platform="${BUILD_PLATFORMS}" \ | |
-f images/Dockerfile \ | |
-t "${IMAGE_NAME}:${IMAGE_TAG}" \ | |
. --push | |
shell: bash |