forked from dfinity/motoko
-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (82 loc) · 3.23 KB
/
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
name: release
# We trigger this on all tags and on the `master` branch. The job
# `changelog` will fail for tags that don’t have a
# changelog entry, so that seems good enough.
# For `master` this check is skipped as well as uploads.
on:
push:
tags:
- '*'
branches:
- 'master'
jobs:
# first check that the changelog is in good order and extract the changelog
# This will fail for non-release tags.
changelog:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- name: Get the version
id: get_version
run: echo version=${{ github.ref_name }} >> "$GITHUB_OUTPUT"
- name: Extract changelog
id: read_changelog
if: startsWith(github.ref, 'refs/tags/')
run: |
export VERSION='${{ steps.get_version.outputs.version }}'
perl -0777 -ne '/^# Motoko compiler changelog\n\n## (??{quotemeta($ENV{VERSION})}) \(\d\d\d\d-\d\d-\d\d\)\n\n(.*?)^##/sm or die "Changelog does not look right for this version\n" ; print $1' Changelog.md > changelog-extract.md
cat changelog-extract.md
# need to mangle to use with $GITHUB_OUTPUT (previously: set-output),
# see https://github.com/svenstaro/upload-release-action/blob/master/README.md
# under "Example for feeding a file from repo to the body tag"
echo "RELEASE_BODY=$(perl -0777 -p -e 's/%/%25/g; s/\n/%0A/g; s/\r/%0D/g' changelog-extract.md)" >> "$GITHUB_OUTPUT"
outputs:
release_body: ${{ steps.read_changelog.outputs.RELEASE_BODY }}
# Now build the release on both linux and darwin
build:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
needs: changelog
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: cachix/cachix-action@v14
if: startsWith(github.ref, 'refs/heads/')
with:
name: ic-hs-test
# NB: No auth token, we don’t want to push new stuff here
- uses: cachix/cachix-action@v14
if: startsWith(github.ref, 'refs/tags/')
with:
name: ic-hs-test
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: cachix watch-store ic-hs-test &
- name: "nix-build"
# these are the dependencies listed in release-files. Sorry for the duplication
run: |
nix-build --max-jobs 1 --arg officialRelease true -A moc -A mo-ide -A mo-doc -A js.moc -A js.moc_interpreter
# Finally do the upload. Hopefully the previous job has uploaded the
# build product to the cachix cache, as we cannot build the darwin products on
# linux
release:
if: startsWith(github.ref, 'refs/tags/')
runs-on: 'ubuntu-latest'
needs: [ changelog, build ]
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v26
- uses: cachix/cachix-action@v14
with:
name: ic-hs-test
# NB: No auth token, we don’t expect to push new stuff here
- run: nix-build --max-jobs 1 --arg officialRelease true release-files.nix
- name: Upload Release Assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: result/*
file_glob: true
body: ${{ needs.changelog.outputs.release_body }}