-
Notifications
You must be signed in to change notification settings - Fork 17
109 lines (94 loc) · 3.83 KB
/
Copy pathpublish.yaml
File metadata and controls
109 lines (94 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Publish Binary
on:
# This action runs whenever a release is published
release:
types:
- published
# Run on pull requests to publish binaries to pull request workflow runs
pull_request:
branches:
- main
paths:
- bin/**
- examples/**
- src/**
- Cargo.*
- rust-toolchain.toml
- .github/workflows/publish.yaml
permissions:
contents: read # Default token to read
jobs:
upload-artifact:
if: ${{ github.repository_owner == 'edera-dev' && (github.event_name == 'release' || github.event.pull_request.head.repo.full_name == github.repository) }}
name: Publish Binary
permissions:
contents: write # Needed to publish binary
strategy:
fail-fast: false
matrix:
platform:
- { os: linux, arch: x86_64, libc: musl, static: true, on: ubuntu-latest }
- { os: linux, arch: x86_64, libc: gnu, static: true, on: ubuntu-latest }
- { os: linux, arch: x86_64, libc: gnu, static: false, on: ubuntu-latest }
env:
TARGET_OS: '${{ matrix.platform.os }}'
TARGET_ARCH: '${{ matrix.platform.arch }}'
TARGET_LIBC: '${{ matrix.platform.libc }}'
STATIC_BINARY: '${{ matrix.platform.static }}'
runs-on: '${{ matrix.platform.on }}'
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@f808768d1510423e83855289c910610ca9b43176 # v2.17.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@5d458579430fc14a04a08a1e7d3694f545e91ce6 # zizmor: ignore[stale-action-refs] -- pinned to stable branch
- name: Install cargo-make
run: cargo install cargo-make
- name: 'Build binary'
run: cargo make --profile release build
- name: 'Set platform name'
id: name
run: |
platform="${TARGET_OS}-${TARGET_ARCH}-${TARGET_LIBC}"
# Adding -static to a musl binary name is redundant
[ "${STATIC_BINARY}" = "true" ] && [ "${TARGET_LIBC}" != "musl" ] && platform="${platform}-static"
echo "platform=$platform" >> $GITHUB_OUTPUT
- name: 'Assemble styrolite executable'
run: |
tag_name="${TAG_NAME}"
[ -z $tag_name ] && tag_name="${DEFAULT_BRANCH}"
export STYROLITE_TAG_NAME="${tag_name}"
export STYROLITE_PLATFORM
export STYROLITE_RELEASE_DIR='target/*/release'
cargo make --profile release assemble-release-assets
env:
TAG_NAME: '${{ github.event.release.tag_name }}'
DEFAULT_BRANCH: '${{ github.event.repository.default_branch }}'
STYROLITE_PLATFORM: '${{ steps.name.outputs.platform }}'
- name: 'Upload styrolite to workflow run'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: styrolite-${{ steps.name.outputs.platform }}
path: |
target/assets/*
- name: generate cultivator token
if: ${{ github.event_name == 'release' }}
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: generate-token
with:
app-id: "${{ secrets.EDERA_CULTIVATION_APP_ID }}"
private-key: "${{ secrets.EDERA_CULTIVATION_APP_PRIVATE_KEY }}"
- name: 'Upload all release artifacts'
if: ${{ github.event_name == 'release' }}
run: |
export STYROLITE_TAG_NAME="${TAG_NAME}"
cargo make --profile release upload-release-assets
env:
GITHUB_TOKEN: "${{ steps.generate-token.outputs.token }}"
TAG_NAME: '${{ github.event.release.tag_name }}'