-
Notifications
You must be signed in to change notification settings - Fork 9
111 lines (107 loc) · 3.91 KB
/
publish-release.yml
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
110
111
# Create a release from the latest tag
name: Publish Release
permissions:
contents: write
on:
# Run this workflow against any branch that updates the TOML file. This can be used to create (pre)releases from any
# branch (e.g. for hotfixes) without affecting the main branch.
push:
paths:
- 'Cargo.toml'
jobs:
# Build and package all the things
build-binaries:
if: |
contains(github.event.head_commit.message, 'chore: version v')
strategy:
matrix:
# For these target platforms
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
arch: x86_64
ext: deb
protoc-arch: linux-x86_64
- target: x86_64-apple-darwin
os: macos-latest
arch: x86_64
ext: pkg
protoc-arch: osx-x86_64
- target: aarch64-apple-darwin
os: macos-latest
config-file: fpm/osx.fpm
arch: aarch64
ext: pkg
protoc-arch: osx-aarch_64
#- target: x86_64-pc-windows-msvc
# os: windows-latest
runs-on: ${{ matrix.os }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- name: Install Protoc
run: |
PROTOC_VERSION=3.20.1
PROTOC_ARCH=${{ matrix.protoc-arch }}
PROTOC_ZIP=protoc-$PROTOC_VERSION-$PROTOC_ARCH.zip
curl --retry 3 --retry-max-time 90 -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -OL https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/$PROTOC_ZIP
sudo unzip -o $PROTOC_ZIP -d /usr/local bin/protoc
sudo unzip -o $PROTOC_ZIP -d /usr/local 'include/*'
rm -f $PROTOC_ZIP
echo "PROTOC=/usr/local/bin/protoc" >> $GITHUB_ENV
echo "PROTOC_INCLUDE=/usr/local/include" >> $GITHUB_ENV
- name: Install Rust
run: |
rustup update stable
rustup default stable
- name: Setup target
run: rustup target add ${{ matrix.target }}
- name: Install ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2' # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Install fpm
run: |
gem install fpm
- name: Run package script
run: |
./ci-scripts/package.sh -a ${{ matrix.arch }} -e ${{ matrix.ext }}
- name: Archive artifact
uses: actions/upload-artifact@v3
with:
name: ceramic-one_${{ matrix.target }}
path: |
ceramic-one_${{ matrix.target }}.tar.gz
release:
needs: [build-binaries]
runs-on: ubuntu-latest
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN_PAT }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PAT }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: check artifacts
run: |
ls artifacts/**/*
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- run: |
git config user.email "[email protected]"
git config user.name "Github Automation"
- id: release
run: |
export TAG=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"')
echo "Releasing "$TAG
# Generate a GitHub pre-release. This will trigger the "prereleased" event that will deploy to Clay. When the
# pre-release is promoted to a release from the GitHub console, the "released" event will trigger and deploy
# to Prod.
current_branch=$(git rev-parse --abbrev-ref HEAD)
gh release create "v${TAG}" -t "v${TAG}" --target "$current_branch" --generate-notes --prerelease artifacts/**/*.tar.gz