Skip to content

untagged-83ad642328b0a2d9cbe6 #105

untagged-83ad642328b0a2d9cbe6

untagged-83ad642328b0a2d9cbe6 #105

Workflow file for this run

on:
release:
types:
- published
workflow_dispatch:
name: Publish binaries
env:
DISABLE_VERSION_CHECK: true
jobs:
validate-version:
name: Validate release (${{ github.event.release.tag_name }})
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: validate version
if: github.event_name == 'release'
run: |
# Extract the version from the Cargo.toml
FP_VERSION=$(cat "Cargo.toml" | grep '^version' | awk '{ split($0,version,"=") ; gsub(/[\ \"]/, "", version[2]) ; print version[2] }')
if [ "v${FP_VERSION}" != "${{ github.event.release.tag_name }}" ]; then
echo "::error file=Cargo.toml::Version set in Cargo.toml (v${FP_VERSION}) does not match release version (${{ github.event.release.tag_name }})"
exit 1
fi
test-release:
needs: validate-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://fiberplanebot:${{ secrets.PRIVATE_GITHUB_TOKEN }}@github.com/"
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --release
build-upload-assets:
name: Build assets for ${{ matrix.build }} (${{ github.event.release.tag_name }})
needs: test-release
runs-on: ${{ matrix.os }}
env:
CARGO: cargo
TARGET_FLAGS: ""
TARGET_DIR: ./target
RUST_BACKTRACE: 1
strategy:
matrix:
build: [linux_x86_64, linux_aarch64, macos_x86_64, macos_aarch64]
include:
- build: linux_x86_64
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux_aarch64
os: ubuntu-latest
rust: stable
target: aarch64-unknown-linux-gnu
- build: macos_x86_64
os: macOS-11
rust: stable
target: x86_64-apple-darwin
- build: macos_aarch64
os: macOS-11
rust: stable
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@v3
- uses: de-vri-es/setup-git-credentials@v2
with:
credentials: "https://fiberplanebot:${{ secrets.PRIVATE_GITHUB_TOKEN }}@github.com/"
- name: cargo fetch
run: cargo fetch --target ${{ matrix.target }}
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Use Cross
run: |
cargo install cross
echo "CARGO=cross" >> $GITHUB_ENV
echo "TARGET_FLAGS=--target ${{ matrix.target }}" >> $GITHUB_ENV
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV
- name: Show command used for Cargo
run: |
echo "cargo command is: ${{ env.CARGO }}"
echo "target flag is: ${{ env.TARGET_FLAGS }}"
echo "target dir is: ${{ env.TARGET_DIR }}"
- name: Build release binary
run: ${{ env.CARGO }} build --verbose --release ${{ env.TARGET_FLAGS }}
- name: Strip release binary (linux and macos)
if: matrix.build == 'linux_x86_64' || matrix.build == 'macos_x86_64'
run: strip "target/${{ matrix.target }}/release/fp"
- name: Prepare artifact
run: |
mkdir -p /tmp/artifact/
cp "target/${{ matrix.target }}/release/fp" /tmp/artifact/
# We only run x86_64 binaries because this is the platform github runners use
- name: Release version information
if: matrix.build == 'linux_x86_64' || matrix.build == 'macos_x86_64'
run: |
target/${{ matrix.target }}/release/fp version -o verbose
target/${{ matrix.target }}/release/fp version -o json > /tmp/artifact/manifest.json
# - name: Strip release binary (arm)
# if: matrix.build == 'macos_aarch64'
# run: |
# docker run --rm -v \
# "$PWD/target:/target:Z" \
# rustembedded/cross:arm-unknown-linux-gnueabihf \
# arm-linux-gnueabihf-strip \
# /target/arm-unknown-linux-gnueabihf/release/rg
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.target }}
path: /tmp/artifact/
if-no-files-found: error
retention-days: 1
publish-artifacts:
name: Publish artifacts to S3 GitHub build artifact (${{ github.event.release.tag_name }})
runs-on: ubuntu-latest
needs: build-upload-assets
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create SHA256 sums for each artifact
run: |
for dir in artifacts/*/; do
pushd "$dir"
sha256sum * > checksum.sha256
popd
done
- name: Prepare artifacts
if: github.event_name == 'release'
run: |
echo "${{ github.event.release.tag_name }}" | cut -c2- > artifacts/version
- name: Configure AWS Credentials
if: github.event_name == 'release'
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::901443922744:role/github_actions
- name: Generate fp reference
run: |
chmod u+x artifacts/x86_64-unknown-linux-gnu/fp
artifacts/x86_64-unknown-linux-gnu/fp markdown > artifacts/reference.md
- name: Sync fp to S3
if: github.event_name == 'release'
run: |
aws s3 sync \
--acl public-read \
--delete \
artifacts/ \
s3://fp.dev/fp/${{ github.event.release.tag_name }}/
aws s3 sync \
--acl public-read \
--delete \
artifacts/ \
s3://fp.dev/fp/latest
- name: Invalidate latest path on CloudFront
if: github.event_name == 'release'
run: |
aws cloudfront create-invalidation \
--distribution-id "${{ secrets.CF_BUILDS_ID }}" \
--paths '/fp/latest*'
- name: Append front-matter to reference
run: cat files/frontmatter.txt artifacts/reference.md > readme_reference.md
- name: Sync fp reference to ReadMe
uses: readmeio/rdme@v8
env:
RDME_API_KEY: ${{ secrets.README_API_KEY }}
with:
rdme: docs readme_reference.md