Support personal tokens #76
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: Release | |
on: | |
push | |
jobs: | |
push-to-sleuth: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ ubuntu-latest, macos-latest, windows-latest ] | |
python-version: [ 3.8 ] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
# Deep clone is needed to get the commit history, to enable running the sleuth deploy command | |
fetch-depth: 0 | |
- name: Set up Python 3.x | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.8' | |
- name: Cache pip | |
uses: actions/cache@v3 | |
with: | |
# This path is specific to Ubuntu | |
path: ~/.cache/pip | |
# Look to see if there is a cache hit for the corresponding requirements file | |
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
${{ runner.os }}- | |
- name: Install pipenv and deps | |
shell: bash | |
run: | | |
python3 -m pip install --upgrade wheel | |
python3 -m pip install -r requirements.txt | |
- name: Generate binary | |
shell: bash | |
run: | | |
pyinstaller app.spec | |
- name: Save binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: client-binary-${{ runner.os }} | |
path: dist | |
- name: Call sleuth (staging) | |
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest' | |
shell: bash | |
env: | |
SLEUTH_TOKEN: ${{ secrets.SLEUTH_STAGING_API_KEY }} | |
run: | | |
dist/sleuth \ | |
-k $SLEUTH_TOKEN \ | |
--baseurl https://staging.sleuth.io \ | |
deploy \ | |
-o sleuth \ | |
-d sleuth-client \ | |
-e staging \ | |
--commit-url-pattern https:/sleuth-io/sleuth-client/commit/REVISION \ | |
--file-url-pattern https:/sleuth-io/sleuth-client/blob/REVISION/PATH | |
- name: Call sleuth (release) | |
if: startsWith(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-latest' | |
shell: bash | |
env: | |
SLEUTH_TOKEN: ${{ secrets.SLEUTH_STAGING_API_KEY }} | |
run: | | |
dist/sleuth \ | |
-k $SLEUTH_TOKEN \ | |
--baseurl https://staging.sleuth.io \ | |
deploy \ | |
-o sleuth \ | |
-d sleuth-client \ | |
-e production \ | |
--commit-url-pattern https:/sleuth-io/sleuth-client/commit/REVISION \ | |
--file-url-pattern https:/sleuth-io/sleuth-client/blob/REVISION/PATH | |
- name: Create github release | |
id: create-release | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: ncipollo/release-action@v1 | |
with: | |
allowUpdates: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload release artifact | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
var fs = require('fs'); | |
const {RUNNER, RELEASE_ID} = process.env | |
const binary = RUNNER === "Windows" ? fs.readFileSync("dist/sleuth.exe") : fs.readFileSync("dist/sleuth"); | |
const name = RUNNER === "Linux" ? "sleuth" : `sleuth-${RUNNER}` | |
const response = await github.rest.repos.uploadReleaseAsset({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
release_id: RELEASE_ID, | |
data: binary, | |
path: "sleuth", | |
name: name, | |
label: `sleuth for ${RUNNER}` | |
}); | |
env: | |
RUNNER: ${{ runner.os }} | |
RELEASE_ID: ${{ steps.create-release.outputs.id }} |