-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: Automatically create tags for releases (#2570)
Whenever we push a tag, this will: * Fetch these assets from the cache ``` motoko-linux64-$VERSION.tar.gz motoko-macos-$VERSION.tar.gz moc-interpreter-$VERSION.js moc-$VERSION.js ``` * Extracts the changes from the changelog, failing hard if it doesn’t _precisely_ look as expected. This also means that nothing happens if you use some tag like `some-revision-I-wanted-to-remember` * Creates a Github Release, with the body of the changelog entry as the body, and the above files as assets. This means one can download motoko from ``` https://github.com/dfinity/motoko/releases/download/0.1.2/motoko-linux64-0.1.2.tar.gz ``` Note that the `nix-build` step needs stuff from both linux and darwin. This will fail if the nix cache was not warm. This could happen if you push the tag while there were still jobs runnig. In that case, just restart the github action manually. With this we can stop deploying via DFINITY’s internal infrastructure. This also removes the hydra-related infrastructure for releases, and updates `CI.md`. Fixes #2566
- Loading branch information
Showing
7 changed files
with
117 additions
and
134 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: release | ||
|
||
# We trigger this on all tags. The job will fail for tags that don’t have a | ||
# changelog entry, so that seems good enough | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
# this assumes that the nix cache is warm | ||
# In particular, we assume we can fetch the darwin build products | ||
# May require restarting the job otherwise | ||
release: | ||
runs-on: 'ubuntu-latest' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: cachix/install-nix-action@v12 | ||
- uses: cachix/cachix-action@v10 | ||
with: | ||
name: ic-hs-test | ||
# NB: No auth token, we don’t expect to push new stuff here | ||
|
||
# from https://github.community/t/how-to-get-just-the-tag-name/16241/7 | ||
- name: Get the version | ||
id: get_version | ||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | ||
|
||
- run: nix-build --max-jobs 1 release-files.nix --argstr releaseVersion '${{ steps.get_version.outputs.VERSION }}' | ||
|
||
- name: Extract changelog | ||
id: read_release | ||
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 set-output, see https://github.com/svenstaro/upload-release-action/pull/49/files | ||
r="$(cat changelog-extract.md)" | ||
r="${r//'%'/'%25'}" | ||
r="${r//$'\n'/'%0A'}" | ||
r="${r//$'\r'/'%0D'}" | ||
echo "::set-output name=RELEASE_BODY::$r" | ||
- name: Upload Release Asset | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
tag: ${{ github.ref }} | ||
file: result/* | ||
file_glob: true | ||
body: ${{ steps.read_release.outputs.RELEASE_BODY }} |
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
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# This file is used by .github/workflows/release.yaml | ||
# to create the files to be uploaded | ||
|
||
# It imports default.nix both for linux and darwin, thus it cannot be part of | ||
# it. | ||
|
||
{ releaseVersion ? "latest" }: | ||
let | ||
nixpkgs = import ./nix { }; | ||
linux = import ./default.nix { system = "x86_64-linux"; internal = true; }; | ||
darwin = import ./default.nix { system = "x86_64-darwin"; internal = true; }; | ||
|
||
as_tarball = dir: derivations: | ||
nixpkgs.runCommandNoCC "motoko-${releaseVersion}.tar.gz" { | ||
allowedRequisites = []; | ||
} '' | ||
tmp=$(mktemp -d) | ||
${nixpkgs.lib.concatMapStringsSep "\n" (d: "cp -v ${d}/bin/* $tmp") derivations} | ||
chmod 0755 $tmp/* | ||
tar -czf "$out" -C $tmp/ . | ||
''; | ||
|
||
as_js = name: derivation: | ||
nixpkgs.runCommandNoCC "${name}-${releaseVersion}.js" { | ||
allowedRequisites = []; | ||
} '' | ||
cp -v ${derivation}/bin/* $out | ||
''; | ||
|
||
release = | ||
nixpkgs.runCommandNoCC "motoko-release-${releaseVersion}" {} '' | ||
mkdir $out | ||
cp ${as_tarball "x86_64-linux" (with linux; [ mo-ide mo-doc moc ])} $out/motoko-linux64-${releaseVersion}.tar.gz | ||
cp ${as_tarball "x86_64-darwin" (with linux; [ mo-ide mo-doc moc ])} $out/motoko-macos-${releaseVersion}.tar.gz | ||
cp ${as_js "moc" linux.js.moc} $out/moc-${releaseVersion}.js | ||
cp ${as_js "moc-interpreter" linux.js.moc_interpreter} $out/moc-interpreter-${releaseVersion}.js | ||
''; | ||
in | ||
release |
This file was deleted.
Oops, something went wrong.