not opt #1304
Workflow file for this run
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
name: Create a snapshot image | |
on: | |
push: | |
workflow_dispatch: | |
inputs: | |
make_release: | |
description: 'Make release' | |
default: false | |
type: boolean | |
schedule: | |
- cron: '30 3 * * WED' | |
env: | |
GH_TOKEN: ${{ github.token }} | |
TEST_RELEASE_PROCESS: false # Set to true if you wish to exercise github triggers without spending time creating real artefacts. | |
jobs: | |
mk_snapshot: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install dfx | |
uses: dfinity/setup-dfx@main | |
- name: Create snapshot | |
id: snapshot | |
run: | | |
if [[ "${TEST_RELEASE_PROCESS}" == true ]] | |
then | |
snapshot_path="snsdemo_snapshot_${{ matrix.os }}.test" | |
echo "Guess what. The file called test has test content. Miracles will never cease." > "$snapshot_path" | |
else | |
snapshot_path="snsdemo_snapshot_${{ matrix.os }}.tar.xz" | |
time bin/dfx-sns-demo-install --verbose | |
time bin/dfx-snapshot-stock-make --snapshot "$snapshot_path" --verbose | |
fi | |
echo "path=$snapshot_path" >> "$GITHUB_OUTPUT" | |
- name: Time snapshot start # See GitHub for the duration of this step. | |
if: ${{ env.TEST_RELEASE_PROCESS != 'true' }} | |
run: bin/dfx-snapshot-restore --snapshot "${{ steps.snapshot.outputs.path }}" | |
- name: "Verify that the stock state behaves as expected" | |
id: test | |
run: bin/dfx-stock-test | |
- name: Stop dfx | |
run: dfx stop | |
- name: Tag if release should be created | |
if: ${{ (github.event_name == 'schedule') || (inputs.make_release)}} | |
id: tag | |
run: | | |
set -euxo pipefail | |
tag_name="$(date +release-%Y-%m-%d)" | |
index=0 | |
# If there is already a tag with the same name, try appending ".${next_integer}". | |
while git show-ref --tags --verify --quiet "refs/tags/${tag_name}"; do | |
echo "Tag ${tag_name} already exists." | |
index=$((index + 1)) | |
tag_name="$(date +release-%Y-%m-%d).${index}" | |
echo "Trying tag ${tag_name}." | |
done | |
echo "Tagging as '${tag_name}'" | |
git tag "${tag_name}" | |
git push origin "refs/tags/${tag_name}" | |
- name: Release | |
uses: ./.github/actions/release | |
with: | |
artefacts: ${{ steps.snapshot.outputs.path }} |