feat: add release workflow (#2)

This commit is contained in:
seth 2023-07-19 02:51:10 +00:00 committed by GitHub
parent 16bd754a82
commit a9de6744a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 90 additions and 92 deletions

30
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,30 @@
name: Release
on:
release:
types: [published, edited]
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.release.tag_name }}
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Build
run: pnpm install && pnpm build
- uses: JasonEtco/build-and-tag-action@v2
env:
GITHUB_TOKEN: ${{ github.token }}

View file

@ -3,7 +3,6 @@ name: "Test"
on:
push:
branches: ["main"]
pull_request:
workflow_call:
workflow_dispatch:
@ -19,12 +18,18 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- name: Build
run: pnpm install && pnpm build
- name: Install Nix
uses: cachix/install-nix-action@v22
- name: Setup nixpkgs
run: nix-channel --add https://nixos.org/channels/nixpkgs-unstable && nix-channel --update
- name: Setup Attic Cache
uses: ./
with:
@ -32,5 +37,5 @@ jobs:
cache: ${{ secrets.ATTIC_CACHE }}
token: ${{ secrets.ATTIC_TOKEN }}
- name: Build
run: nix-build test.nix
- name: Build Nix Package
run: nix build -f test.nix

View file

@ -18,5 +18,5 @@ inputs:
runs:
using: "node16"
main: "dist/index.js"
post: "dist/post.js"
post: "dist/index.js"
post-if: "success()"

29
dist/index.js vendored

File diff suppressed because one or more lines are too long

9
dist/post.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,9 +1,9 @@
{
"name": "@ryanccn/attic-action",
"version": "0.1.0",
"main": "dist/index.js",
"description": "Cache Nix derivations with attic",
"scripts": {
"build": "esbuild src/index.ts src/post.ts --outdir=dist --platform=node --format=cjs --bundle --minify-whitespace --minify-syntax",
"build": "esbuild src/index.ts --outdir=dist --platform=node --format=cjs --bundle --minify-whitespace --minify-syntax",
"format": "prettier --write ."
},
"keywords": [],

View file

@ -1,9 +1,18 @@
import { install } from "./stages/install";
import { configure } from "./stages/configure";
import { push } from "./stages/push.ts";
import { getState, saveState } from "@actions/core";
const isPost = !!getState("isPost");
const main = async () => {
await install();
await configure();
};
if (!isPost) {
saveState("isPost", true);
main();
} else {
push();
}

View file

@ -1,7 +0,0 @@
import { push } from "./stages/push";
const main = async () => {
await push();
};
main();

View file

@ -16,7 +16,6 @@ export const install = async () => {
if (!r.ok) {
core.setFailed(`Action failed with error: ${r.statusText}`);
core.endGroup();
process.exit(1);
}