This repository has been archived by the owner on Jul 2, 2024. It is now read-only.
new release v3.3.0 #106
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: Update nix flake | |
on: | |
push: | |
branches: | |
- 'v*.*.*' | |
jobs: | |
fetch-repo-and-deps-hashes: | |
runs-on: ubuntu-latest | |
outputs: | |
REPOSITORY_HASH: ${{ steps.escape-repository-hash.outputs.REPOSITORY_HASH_ESCAPED }} | |
NPM_DEPS_HASH_ESCAPED: ${{ steps.escape-npm-deps-hash.outputs.NPM_DEPS_HASH_ESCAPED }} | |
MAJOR_NODE_VERSION: ${{ steps.extract-major-node-version.outputs.MAJOR_NODE_VERSION }} | |
PACKAGE_VERSION: ${{ steps.extract-package-version.outputs.PACKAGE_VERSION }} | |
steps: | |
- name: get tag version | |
id: get-cleaned-tag | |
run: echo "CLEANED_TAG=$(echo ${{ github.ref_name }} | sed 's/v//')" >> $GITHUB_OUTPUT | |
- name: checkout clever-tools repository | |
uses: actions/checkout@v4 | |
with: | |
repository: 'CleverCloud/clever-tools' | |
ref: ${{ steps.get-cleaned-tag.outputs.CLEANED_TAG }} | |
- run: ls | |
- name: Install Nix | |
uses: cachix/install-nix-action@v26 | |
with: | |
github_access_token: ${{ secrets.PERSO_TOKEN }} | |
nix_path: nixpkgs=channel:nixos-unstable | |
- name: Install prefetch-npm-deps | |
run: nix-env -i prefetch-npm-deps -f '<nixpkgs>' | |
- name: Install nix-prefetch-git | |
run: nix-env -i nix-prefetch-git -f '<nixpkgs>' | |
- name: nix-prefetch-git | |
id: nix-prefetch-git | |
run: | | |
{ | |
echo 'NIX_PREFETCH_GIT_RESULT<<EOF' | |
echo "$(nix-prefetch-git --url https://github.com/CleverCloud/clever-tools --rev ${{ steps.get-cleaned-tag.outputs.CLEANED_TAG }} --quiet)" | |
echo EOF | |
} >> $GITHUB_OUTPUT | |
- name: get-repository-hash | |
id: get-repository-hash | |
run: echo "REPOSITORY_HASH=${{ fromJSON(steps.nix-prefetch-git.outputs.NIX_PREFETCH_GIT_RESULT).hash }}" >> $GITHUB_OUTPUT | |
- name: escape repository hash | |
id: escape-repository-hash | |
run: echo "REPOSITORY_HASH_ESCAPED=$(echo ${{ steps.get-repository-hash.outputs.REPOSITORY_HASH }} | sed 's/\//\\\\\//gip')" >> $GITHUB_OUTPUT | |
- name: get-npm-deps-hash | |
id: get-npm-deps-hash | |
run: echo "NPM_DEPS_HASH=$(prefetch-npm-deps package-lock.json)" >> $GITHUB_OUTPUT | |
- name: escape npm deps hash | |
id: escape-npm-deps-hash | |
run: echo "NPM_DEPS_HASH_ESCAPED=$(echo ${{ steps.get-npm-deps-hash.outputs.NPM_DEPS_HASH }} | sed 's/\//\\\\\//gip')" >> $GITHUB_OUTPUT | |
- name: get package.json content | |
id: get_package_json_content | |
run: | | |
{ | |
echo 'PACKAGE_JSON_CONTENT<<EOF' | |
cat ./package.json | |
echo EOF | |
} >> $GITHUB_OUTPUT | |
- name: extract Node.js version | |
id: extract_node_version | |
run: echo "NODE_VERSION=${{ fromJSON(steps.get_package_json_content.outputs.PACKAGE_JSON_CONTENT).volta.node }}" >> $GITHUB_OUTPUT | |
- name: extract major Node.js version | |
id: extract-major-node-version | |
run: | | |
echo "MAJOR_NODE_VERSION=$(echo ${{ steps.extract_node_version.outputs.NODE_VERSION }} | sed 's/\..\+//g')" >> $GITHUB_OUTPUT | |
- name: extract package version | |
id: extract-package-version | |
run: | | |
echo "PACKAGE_VERSION=${{ fromJSON(steps.get_package_json_content.outputs.PACKAGE_JSON_CONTENT).version }}" >> $GITHUB_OUTPUT | |
update-flake-with-new-hashes: | |
runs-on: ubuntu-latest | |
needs: fetch-repo-and-deps-hashes | |
steps: | |
- name: Install Nix | |
uses: cachix/install-nix-action@v26 | |
with: | |
github_access_token: ${{ secrets.PERSO_TOKEN }} | |
nix_path: nixpkgs=channel:nixos-unstable | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }} | |
- name: update package version | |
run: sed -r -i "s/version = \"([0-9]\.?)+\";/version = \"${{ needs.fetch-repo-and-deps-hashes.outputs.PACKAGE_VERSION }}\";/" flake.nix | |
- name: update npm deps hash | |
run: sed -i "s/npmDepsHash = .\+$/npmDepsHash = \"${{ needs.fetch-repo-and-deps-hashes.outputs.NPM_DEPS_HASH_ESCAPED }}\";/" flake.nix | |
- name: update git repo hash | |
run: sed -i "s/hash = .\+/hash = \"${{ needs.fetch-repo-and-deps-hashes.outputs.REPOSITORY_HASH }}\";/" flake.nix | |
- name: update Node.js version | |
run: sed -r -i "s/(nodejs-.._x)/nodejs-${{ needs.fetch-repo-and-deps-hashes.outputs.MAJOR_NODE_VERSION }}_x/gm" flake.nix | |
- name: update flake deps | |
run: nix flake update | |
- name: config git | |
run: | | |
git config --global user.name 'Florian Sanders' | |
git config --global user.email 'florian.sanders@clever-cloud.com' | |
- name: git status | |
run: git status | |
- name: cat flake | |
run: cat flake.nix | |
- name: create tag | |
run: | | |
git add . | |
git commit -m "new release ${{ github.ref_name }}" | |
git push origin ${{ github.ref_name }}:master | |
git tag -a ${{ github.ref_name }} -m "Release ${{ github.ref_name }}" | |
git push -f --tags | |
git push -f |